compare static method
compareTo function with ascending/descending and ignore case
Implementation
static int? compare(dynamic a, dynamic b, {bool ascending = true, bool ignoreCase = true})
{
if ((a == null) && (b == null)) return 0;
if ((a == null) && (b != null)) return (ascending == true) ? -1 : 1;
if ((a != null) && (b == null)) return (ascending == true) ? 1 : -1;
if ((a is String) && (ignoreCase == true)) a = a.toLowerCase();
if ((b is String) && (ignoreCase == true)) b = b.toLowerCase();
if (ascending == true)
return a.compareTo(b);
else return b.compareTo(a);
}