Say I have an array of numbers:
var foo = [20, 10, 03, 04, 02, 15, 01];
I need to sort the numbers using array.sort
so the result has everything smaller than ten is after ten:
[10, 15, 20, 01, 02, 03, 04]
Is a simple .sort enough? Or will I have to store values in external arrays and then pull them in (even then i'm not sure how to do it just in the sort method)? The closest thing I could find was this example, but it's written in c# and the logic isn't really explained.
The closest logic I can think of is to splice
all numbers lower than 10 and put them in another array. On sort complete, sort the new array from smallest to largest and add on the end of the initial array. However, there's no sort callback of any kind.
I'm trying to use this in conjunction with KnockoutJS' inline sort implementation, so that's why I'm trying to stick to the sort method.