Sorting an array of objects with the sortBy method of Prototype

Here is an example of how easy it is to sort an array of objects using the Enumerable.sortBy method of the Prototype framework: varobj1={lastName:"Lacava",firstName:"Alessandro"};varobj2={lastName:"Brown",firstName:"John"};varobj3={lastName:"Simpson",firstName:"Bart"};vararr=[obj1,obj2,obj3];//order by last name varsorted=arr.sortBy(function(obj){returnobj.lastName.toLowerCase();});varstr="";sorted.each(function(obj,index){str+=index+1+" - "+obj.lastName+" "+obj.firstName;});//display the elements ordered by last name document.write(str);