mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 01:06:21 +01:00
Use stable sort for album
This commit is contained in:
parent
8de5597575
commit
1a5fc2bbe2
2 changed files with 9 additions and 1 deletions
|
@ -137,7 +137,7 @@ class AlbumTimeSortProvider extends AlbumReversibleSortProvider {
|
||||||
return Tuple2(
|
return Tuple2(
|
||||||
prevFileTime ?? DateTime.fromMillisecondsSinceEpoch(0), e);
|
prevFileTime ?? DateTime.fromMillisecondsSinceEpoch(0), e);
|
||||||
})
|
})
|
||||||
.sorted((x, y) {
|
.stableSorted((x, y) {
|
||||||
if (isAscending) {
|
if (isAscending) {
|
||||||
return x.item1.compareTo(y.item1);
|
return x.item1.compareTo(y.item1);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
extension IterableExtension<T> on Iterable<T> {
|
extension IterableExtension<T> on Iterable<T> {
|
||||||
/// Return a new sorted list
|
/// Return a new sorted list
|
||||||
List<T> sorted([int compare(T a, T b)]) => this.toList()..sort(compare);
|
List<T> sorted([int compare(T a, T b)]) => this.toList()..sort(compare);
|
||||||
|
|
||||||
|
/// Return a new stable sorted list
|
||||||
|
List<T> stableSorted([int compare(T a, T b)]) {
|
||||||
|
final tmp = this.toList();
|
||||||
|
mergeSort(tmp, compare: compare);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/// Return a string representation of this iterable by joining the result of
|
/// Return a string representation of this iterable by joining the result of
|
||||||
/// toString for each items
|
/// toString for each items
|
||||||
String toReadableString() => "[${join(', ')}]";
|
String toReadableString() => "[${join(', ')}]";
|
||||||
|
|
Loading…
Reference in a new issue