Skip to content

Instantly share code, notes, and snippets.

@britannio
Last active January 9, 2022 19:48
Show Gist options
  • Save britannio/5c2bacc00dda84ff68577055eb51bfcc to your computer and use it in GitHub Desktop.
Save britannio/5c2bacc00dda84ff68577055eb51bfcc to your computer and use it in GitHub Desktop.
Iterable Equality Ignoring Ordering in Dart
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