News for hackers. Stuff that matters.
Re:Advanced Javascript tips and tricks by omaranto on Tuesday July 05, 2011 @05:02AM (#2729139)
Fisher-Yates is a better idea, of course, since it is pretty short and runs in linear time, but if someone insists on a sort-based one-linear this should work:

  list.map(function (t) { return [Math.random(), t]; }).sort().map(function (t) { return t[1]; })
Re:Advanced Javascript tips and tricks by omaranto on Tuesday July 05, 2011 @09:25AM (#2729710)
Argh, I missed the edit time window: "one-linear", should be, of course, "one-liner". Fisher-Yates is O(n), but the sort makes this algorithm Omega(n log n).
Re:Advanced Javascript tips and tricks by __rkaup__ on Wednesday July 06, 2011 @03:39AM (#2732907)
What's 'Omega'?
Re:Advanced Javascript tips and tricks by throw_away on Wednesday July 06, 2011 @04:06AM (#2732954)
omega() is like the opposite of O(). it means "at least" rather than "at most". — http://en.wikipedia.org/wiki/Big_Oh_notation#Family_of_Bachm...
Re:Advanced Javascript tips and tricks by tomstuart on Tuesday July 05, 2011 @06:06AM (#2729267)
Fisher-Yates is also in-place, just like Array.prototype.sort.