List: Added support for neg,0,pos comparer for sorting.
List: Added support for neg,0,pos comparer for sorting.

--- a/include/boilerplate.hpp
+++ b/include/boilerplate.hpp
@@ -132,6 +132,10 @@
 	return (u16)(rng64() >> 48);
 }
 
+u8 random_char() {
+	return (u8)(rng64() >> 56);
+}
+
 // Produces a random integer in the range [range_min..range_max).
 s64 random_range(s64 range_min, s64 range_max) {
 	s64 width = range_max - range_min;
@@ -149,18 +153,10 @@
 	return num;
 }
 
-// List type valid up to 65536 members.
+// List type valid up to lots and lots of members.
 template <typename T>
 struct List {
 private:
-	static bool gtFunc(T l, T r) {
-		return l > r;
-	}
-
-	static bool ltFunc(T l, T r) {
-		return l < r;
-	}
-
 	static s8 default_comparer(T l, T r) {
 		if (l < r) {
 			return -1;
@@ -200,7 +196,7 @@
 		*BucketPtr(bucketIdx) = (T*)malloc(sizeof(T) * ITEMS_PER_BUCKET);
 	}
 
-	s64 qs_partition(u64 ltIdx, u64 rtIdx, u64 pvtIdx, bool (*comp_func)(T, T)) {
+	s64 qs_partition(u64 ltIdx, u64 rtIdx, u64 pvtIdx, s8 (*comp_func)(T, T), bool reversed) {
 		// Fetch the value of the pivot point.
 		T pvtVal = GetItem(pvtIdx);
 
@@ -217,8 +213,8 @@
 		u64 strIdx = ltIdx;
 
 		for (u64 idx = ltIdx; idx < rtIdx; idx++) {
-			//
-			if ((*comp_func)(GetItem(idx), pvtVal)) {
+			s8 result = (*comp_func)(GetItem(idx), pvtVal);
+			if ((!reversed && result < 0) || (reversed && result > 0)) {
 				swap1 = GetItem(strIdx);
 				swap2 = GetItem(idx);
 
@@ -238,18 +234,18 @@
 		return strIdx;
 	}
 
-	void qs_region(u64 ltIdx, u64 rtIdx, bool (*comp_func)(T, T)) {
+	void qs_region(u64 ltIdx, u64 rtIdx, s8 (*comp_func)(T, T), bool reversed) {
 		if (ltIdx < rtIdx && rtIdx < Count()) {
 			// Select a random pivot point between ltIdx and rtIdx.  The location is not important,
 			// and picking randomly may provide speedup in some cases.
 			u64 pvtIdx = random_range(ltIdx, rtIdx);
 
 			// L"Sift" the array around the pivot value, and record its new location.
-			s64 newIdx = qs_partition(ltIdx, rtIdx, pvtIdx, comp_func);
+			s64 newIdx = qs_partition(ltIdx, rtIdx, pvtIdx, comp_func, reversed);
 
 			// Since the L"sifted" regions are not sorted, sort them.
-			qs_region(ltIdx, newIdx - 1, comp_func);
-			qs_region(newIdx + 1, rtIdx, comp_func);
+			qs_region(ltIdx, newIdx - 1, comp_func, reversed);
+			qs_region(newIdx + 1, rtIdx, comp_func, reversed);
 		}
 	}
 
@@ -257,7 +253,7 @@
 	static const u32 DEFAULT_ITEMS_PER_BUCKET = 256;
 	static const u32 DEFAULT_MAX_BUCKETS = 256;
 
-	bool (*comparer)(T, T);
+	s8 (*comparer)(T, T);
 
 	u64 CurrentCapacity() {
 		return (u64)ITEMS_PER_BUCKET * (u64)bucketCount;
@@ -359,42 +355,36 @@
 		return *idx < Count();
 	}
 
-	bool IsSorted(bool (*comp_func)(T, T)) {
+	bool IsSorted(s8 (*comp_func)(T, T), bool reversed) {
 		T first = GetItem(0);
 		for (u32 idx = 1; idx < Count(); idx++) {
-			if ((*comp_func)(GetItem(idx), first)) {
+			s8 result = (*comp_func)(GetItem(idx), first);
+			if (reversed && result > 0) {
 				return false;
 			}
+			else if (!reversed && result < 0) {
+				return false;
+			}
 		}
 
 		return true;
 	}
 
 	bool IsSorted(bool reversed) {
-		if (reversed) {
-			return IsSorted(&gtFunc);
-		}
-		else {
-			return IsSorted(&ltFunc);
-		}
+		return IsSorted(comparer, reversed);
 	}
 
 	bool IsSorted() {
-		return IsSorted(false);
-	}
-
-	void Sort(bool (*comp_func)(T, T))
+		return IsSorted(comparer, false);
+	}
+
+	void Sort(s8 (*comp_func)(T, T), bool reversed)
 	{
-		qs_region(0, Count() - 1, comp_func);
+		qs_region(0, Count() - 1, comp_func, reversed);
 	}
 
 	void Sort(bool reversed) {
-		if (reversed) {
-			Sort(&gtFunc);
-		}
-		else {
-			Sort(&ltFunc);
-		}
+		Sort(comparer, reversed);
 	}
 
 	void Sort() {
@@ -430,14 +420,14 @@
 		MAX_BUCKETS(max_buckets),
 		bucketCount(0),
 		itemCount(0),
-		comparer(&ltFunc)
+		comparer(&default_comparer)
 	{
 		buckets = (T**)malloc(sizeof(T*) * MAX_BUCKETS);
 	}
 
 	List() : List(DEFAULT_MAX_BUCKETS, DEFAULT_ITEMS_PER_BUCKET) {}
 
-	List(u64 capacity, bool contiguous_small_list) : bucketCount(0), itemCount(0), comparer(&ltFunc) {
+	List(u64 capacity, bool contiguous_small_list) : bucketCount(0), itemCount(0), comparer(&default_comparer) {
 		if (capacity > 0xfffffffe00000001)
 		{
 			capacity = 0xfffffffe00000001;