Maybe like that
copyarray .@tmp_points, .points, .size;// points in temp array
.@tmp = .size;
while( .@tmp ) {
.@max = .@tmp_points[0];
.@index = 0;
for ( .@i = 0; .@i < .@tmp; .@i++ )
if ( .@max < .@tmp_points[.@i] ) {
.points[ ( .size - .@tmp ) ] = .@tmp_points[.@i];
.@index = .@i;
}
deletearray .@tmp_points[.@index], 1;
.@tmp--;
}