documentcloud/underscore — pull request #1084 by billymoon (2013-04-26 22:12:06+00:00)
Title: Add limit to shuffle function for shuffling only a few elements of the array

add limit for shuffle function, allowing shuffling of only the number of elements needed (for example, only shuffling the 9 cards required for a heads up game of holdem rather than the whole deck).

This is a feature of the Fisher-Yates shuffle that can save time if you only need to pick a few values from a large set.

Returns an array of random elements up to the `limit`...

var cards = _.shuffle(deck,9) // returns 9 random cards from the deck