Index: sdk/lib/collection/list.dart |
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart |
index 0e0c6116445554ade256019919d6f97b991f0044..74cda1df9427ac81e091679df912bba3f770520a 100644 |
--- a/sdk/lib/collection/list.dart |
+++ b/sdk/lib/collection/list.dart |
@@ -301,6 +301,18 @@ abstract class ListMixin<E> implements List<E> { |
Sort.sort(this, compare); |
} |
+ void shuffle() { |
+ Random random = new Random(); |
+ int length = this.length; |
+ while (length > 1) { |
+ int pos = random.nextInt(length); |
+ length -= 1; |
+ var tmp = this[length]; |
+ this[length] = this[pos]; |
+ this[pos] = tmp; |
+ } |
+ } |
+ |
Map<int, E> asMap() { |
return new ListMapView(this); |
} |