Fixed the incorrect sorting result in IE/Chrome

Fix: the original sort function does not follow ECMA standards and will generate an incorrect result in IE/Chrome.
Fix: the sorting result is unstable.