Skip to content Skip to sidebar Skip to footer

Js Sorting By Multiple Columns Not Working In IE And Safari

In this question the data is sorted by most then if most is equal it is sorted by who picked more fruit when the two workers worked on the same day. as shown below var workers

Solution 1:

You are relying on the order of arguments a and b to the callback supplied to sort when you attempt to lookup information in workers:

b["sd-" + a.id + b.id] - a["sd-" + a.id + b.id] 

This ordering is not predictable and does not appear to be consistent across browsers. On Firefox, I get the following look-ups:

sd-111222 
sd-444555

On Safari, I get these (which are the reverse order do not exist):

sd-222111
sd-555444

You shouldn't rely on this ordering. All you know is that you are comparing some element from the array called a to some other element in the array called b. You can't be sure of anything else.


Post a Comment for "Js Sorting By Multiple Columns Not Working In IE And Safari"