array.sort_custom [method]

array.sort_custom( callable[, bool reverse ] )

sorts the array using the callable for comparisons, returns the array for chaining

This function is considerably slower than array.sort or array.sort_mapped so prefer those if performance matters.

a = [ 6, 8, 7, 5 ];
// this code will sort numbers into odd/even ones and in ascending order
a.sort_custom( function(a,b){return a-b+(b%2-a%2)*1000; } ); // a = [5,7,6,8]