greaterThanIterable<T> function
For > and < operators for Iterables
Implementation
bool greaterThanIterable<T>(Iterable<T> it1, Iterable<T> it2) {
if (!(it1.first is num && it2.first is num) &&
!(it1.first is String && it2.first is String) &&
!(it1.first is Iterable && it2.first is Iterable)) {
return false;
}
if (deepEquals(it1, it2)) {
return false;
}
int minLength = min(it1.length, it2.length);
List<T> l1 = List.from(it1);
List<T> l2 = List.from(it2);
for (int i = 0; i < minLength; i++) {
if (!(l1[i] is num && l2[i] is num) &&
!(l1[i] is String && l2[i] is String) &&
!(l1[i] is Iterable && l2[i] is Iterable)) {
return false;
}
if (l1[i] is String && l2[i] is String) {
if (greaterThanString(l1[i].toString(), l2[i].toString())) {
return true;
} else {
continue;
}
}
if (l1[i] is num && l2[i] is num) {
if (double.parse(l1[i].toString()) > double.parse(l2[i].toString())) {
return true;
} else {
continue;
}
} else {
if (deepEquals(l1[i] as Iterable, l2[i] as Iterable)) {
continue;
} else {
return greaterThanIterable(l1[i] as Iterable, l2[i] as Iterable);
}
}
}
return (l1.length > l2.length);
}