mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
Random order
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
* then we sort by this key. Since the key is random, the sorted array will have
|
||||
* the original elements in a random order.
|
||||
*/
|
||||
export const shuffle = <T>(xs: T[]) =>
|
||||
export const shuffled = <T>(xs: T[]) =>
|
||||
xs
|
||||
.map((x) => [Math.random(), x])
|
||||
.sort()
|
||||
.map(([, x]) => x);
|
||||
.map(([, x]) => x) as T[];
|
||||
|
Reference in New Issue
Block a user