In JavaScript there is a sort function for arrays. Though, the result will take into account the case of each character. Therefore you can have something like the following happen.var a = ["john", "April", "tim", "Zoe"];
a = a.sort();
// a is now ["April", "Zoe", "john", "tim"]
Using MooTools you add a method to the Array object which will allow you to sort while being insensitive to case.
-
Array.insensitiveSort in MooTools
2 Comments Posted on October 9th, 2009Read More › -
Prototype's Element.identify() in MooTools
0 Comments Posted on September 22nd, 2009Read More ›Prototype.js has a method, Element.identify(), that can be very useful. It is used to retrieve the ID of a given element. If one does not exist it first generates and assigns one and then returns that.
To implement this in MooTools you can add the following code.
Element.implement({
identify: function() {
if(!$type(this.get('id')))
this.set('id', genID(0));
return this.get('id');
function genID(num) {
num++;
if(!$type($(num.toString())))
return num;
return genID(num);
}
}
});