Skip to content
Snippets Groups Projects
Commit 67cd9fbc authored by deuce's avatar deuce
Browse files

Re-write sortListByProperty()

parent b960ad18
No related branches found
No related tags found
No related merge requests found
......@@ -422,18 +422,12 @@ function compressList(list)
function sortListByProperty(list,prop)
{
var data=compressList(list);
var numItems=data.length;
for(n=0; n<numItems; n++) {
for(m=0; m<(numItems-1); m++) {
if(data[m][prop] < data[m+1][prop]) {
var holder = data[m+1];
data[m+1] = data[m];
data[m] = holder;
}
}
}
return data;
}
\ No newline at end of file
return data.sort(function(a,b) {
if(a[prop] < b[prop])
return -1;
if(a[prop] > b[prop])
return 1;
return 0;
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment