Improving the orderBy command in JS