As a trivia question, I'm trying to write a javascript function that returns its variable number of arguments in sorted (normal lexicographic) order.
Having never dealt with javascript before, I came across the "arguments" object, which seems to work somewhat like an array but without having the standard array functions -- therefore I seem to need to copy its contents into a "real" array.
Is there a shorter/more concise way of doing this (preferably in a single line)?
function sortArgs()
{
args = new Array();
for (var i = 0; i < arguments.length; i++)
args[i] = arguments[i];
return args.sort();
}
UPDATE:
Brownie points for explaining how your answer works, since I'm new to JS. I understand slice(), but not the rest of it..