WTF javascript sort method