jquery order by specific order

Solutions on MaxInterview for jquery order by specific order by the best coders in the world

showing results for - "jquery order by specific order"
Max
03 Oct 2016
1var arr = arr.sort(function(a,b) {
2    return order.indexOf( a.key ) - order.indexOf( b.key );
3    //for the sake of recent versions of Google Chrome use:
4    //return a.key.charCodeAt(0) > b.key.charCodeAt(0); or return a.key.charCodeAt(0) - b.key.charCodeAt(0);
5});
6
Adam
20 Jan 2020
1var arr = arr.sort(function(a,b) {
2    return order.indexOf( a.key ) - order.indexOf( b.key );    
3});
4
similar questions
queries leading to this page
jquery order by specific order