Fix array sorting bug

(was breaking PhantomJS tests)