According to the MDN spec, Javascript\'s sort() function is \'unstable\' (does not maintain input order for identical elements).
Ironically, it seems that Firefox cu
Here is an example of a working stable sort. It adds an extra parameter for the original item index which is used if items are otherwise "equal". The code should work in any browser in use.
Note that it is an example only and should be modified to suit your particular circumstance.
0
2
0
The extra parameter is added as an attribute and could be removed when elements are added back to the container to keep things clean.