> For the complete documentation index, see [llms.txt](https://pahutyakv.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pahutyakv.gitbook.io/docs/randomly/.collection.md).

# .Collection

`Randomly.Collection` provides advanced random selection and shuffling utilities for collections. Supports equal probability selection, weighted selection, and selection with animation curves.

***

### <mark style="color:$success;">Choice</mark>

* `Choice(list)` – Selects a random element from the list with equal probability.
* `Choice(list, weights)` – Selects a random element from the list using the provided weights.
* `Choice(list, weightCurve)` – Selects a random element from the list using an AnimationCurve to determine weights.
* `ChoicePop(list)` – Selects a random element from the list and removes it from the list.
* `ChoiceIndex(list)` – Returns a random index from the list with equal probability.

***

### <mark style="color:$success;">Take</mark>

* `Take(list, count)` – Returns a list of random elements from the list with equal probability.
* `Take(list, weights, count)` – Returns a list of random elements from the list using weights.
* `Take(list, weightCurve, count)` – Returns a list of random elements from the list using an AnimationCurve to determine weights.
* `TakePop(list, count)` – Returns a list of random elements from the list and removes them from the list.
* `TakeIndexes(list, count)` – Returns a list of random indexes from the list.

***

### <mark style="color:$success;">Shuffle</mark>

* `Shuffle(list)` – Shuffles the elements of the list in-place.
* `ShuffleSection(list, start, end)` – Shuffles a specific section of the list in-place.
* `Shuffled(list)` – Returns a new shuffled copy of the list without modifying the original list.

***

{% code title="Example.cs" %}

```csharp
// Get random list element
List<int> myList = new List<int>() { 4, 7, 2, 8, 12 };
int v = Randomly.Collection.Choice(myList);

// Get random 2 list elements using weights
List<float> wights = new List<float>() { 0.2f, 0.2f, 0.1f, 0.1f, 0.4f };
List<int> values = Randomly.Collection.Take(myList, weights, 2)
```

{% endcode %}
