The following code throws an error an does not sort the right way:
TypeError: Can't call method "call" on unblessed reference at
/usr/local/share/perl/5.8.7/JE/Object/Array.pm line 601.
Code:
function UserSubmit(user,submits)
{
this.user=user;
this.submits=submits;
}
function UserSubmitSort (a, b)
{
return a.submits - b.submits;
}
var um=new Array(
new UserSubmit("a",3),
new UserSubmit("bc",1),
new UserSubmit("add",35),
new UserSubmit("eaea",23)
);
um.sort(UserSubmitSort);
for(i=0;i<um.length;i++)
{
print(um[i].submits+" "+um[i].user+"\n");
}