Skip to content

Instantly share code, notes, and snippets.

@eventomer
Last active December 11, 2015 02:29
Show Gist options
  • Save eventomer/4531152 to your computer and use it in GitHub Desktop.
Save eventomer/4531152 to your computer and use it in GitHub Desktop.
'great finds' are given preferred sorting, their sort order is cut in half.
...
mainQuery.find({
success:function(results){
//'great finds' are given preferred sorting, their sort order is cut in half.
for(var i = 0; i<results.length; i++){
if(results[i].get('ribbon')=='GREAT_FIND'){
results.insert(i/2,results.remove(i).pop());
}
}
response.success(results);
},
error: function(error) {
response.error(error);
}
});
}
Array.prototype.insert = function (index, item) {
this.splice(index, 0, item);
};
Array.prototype.remove = function (index) {
return this.splice(index, 1);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment