Sorting in javascript
Recently in my project I needed to sort an object list on the basis of object name. For the same purpose I created the following function
[java]
function sortList(objList) {
objList.sort(sortByName);
}
function sortByName(a, b) {
var x = a.name;
var y = b.name;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
[/java]
This function sorts an object list on the basis of name of object. Hope it helps
Sachin Anand
sachin[at]intelligrape[dot]com