You are currently viewing the gmlscripts.pro static mirror. Forum access and script submissions are not available through this mirror.

Invert gmlscripts.pro

array_sort

Returns a sorted version of a given array.

array[0] = "Juliett";
array[1] = "Victor";
array[2] = "Mike";
array[3] = "Charlie";
array[4] = "Romeo";
array[5] = "Oscar";

sorted = array_sort(array, true);

//  sorted[0] == "Charlie";
//  sorted[1] == "Juliett";
//  sorted[2] == "Mike";
//  sorted[3] == "Oscar";
//  sorted[4] == "Romeo";
//  sorted[5] == "Victor";
array_sort(array, ascend)
Returns a sorted version of a given array.
COPY/// array_sort(array, ascend)
//
//  Returns a sorted version of a given array.
//
//      array        array to sort, array
//      ascend       ascending (true) or descending (false) order, boolean
//
/// gmlscripts.pro/license
{
    var array = argument0;
    var ascend = argument1;
    var list = ds_list_create();
    var count = array_length_1d(array);
    for (var i=0; i<count; i++) list[| i] = array[i];
    ds_list_sort(list, ascend);
    for (i=0; i<count; i++) array[i] = list[| i];
    ds_list_destroy(list);
    return array;
}

Contributors: paul23, xot

GitHub: View · Commits · Blame · Raw