Last active
January 9, 2022 19:48
-
-
Save britannio/5c2bacc00dda84ff68577055eb51bfcc to your computer and use it in GitHub Desktop.
Iterable Equality Ignoring Ordering in Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:collection/collection.dart'; | |
void main() { | |
print([1,2,3].isEqualToIgnoringOrdering({3,2,1})); // true | |
} | |
extension IsEqualToIgnoringOrdering<T> on Iterable<T> { | |
bool isEqualToIgnoringOrdering(Iterable<T> other) { | |
return const UnorderedIterableEquality().equals(this, other); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment