i\'ve built this sample code based on a real problem I have in an application. I\'ve got a custom sort procedure to sort jQuery arrays. A container contains a list of items
Your sort procedure is subtly wrong: you need to account for equalities as well, and boolean is not the correct return type (see addendum).
Do this:
return value1 - value2;
instead of:
return value1 > value2;
Addendum:
The general form of a sort comparison function f(A,B) needs to return > 0 if A > B, < 0 if A < B, and 0 if no alteration needs to occur. Returning a boolean gets you caught by falsey values not representing what you think they do.