Skip to content

Instantly share code, notes, and snippets.

@aitoraznar
Created July 20, 2015 07:16
Show Gist options
  • Save aitoraznar/6d6ad4356fb8933514cc to your computer and use it in GitHub Desktop.
Save aitoraznar/6d6ad4356fb8933514cc to your computer and use it in GitHub Desktop.
function sortByAttribute(gameList, sortAttributesList) {
if (!gameList) return; //Ensure we data data to sort
if (!sortAttributesList) return gameList; //Return same list if no sort attribute provided
sortAttributesList = typeof sortAttributesList === 'string' ? [sortAttributesList].slice() : sortAttributesList;
sortAttributesParams = getSortAttributesWithOrder(sortAttributesList);
return gameList.slice().sort(function (a, b) {
return sortByAttrStrategy(a, b, sortAttributesParams.slice());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment