#include public Plugin:myinfo = { name = "Sorting Test", author = "AlliedModders LLC", description = "Tests sorting functions", version = "1.0.0.0", url = "http://www.sourcemod.net/" }; public OnPluginStart() { RegServerCmd("test_sort_ints", Command_TestSortInts) RegServerCmd("test_sort_floats", Command_TestSortFloats) RegServerCmd("test_sort_strings", Command_TestSortStrings) RegServerCmd("test_sort_1d", Command_TestSort1D) RegServerCmd("test_sort_2d", Command_TestSort2D) RegServerCmd("test_adtsort_ints", Command_TestSortADTInts) RegServerCmd("test_adtsort_floats", Command_TestSortADTFloats) RegServerCmd("test_adtsort_strings", Command_TestSortADTStrings) RegServerCmd("test_adtsort_custom", Command_TestSortADTCustom) } /***************** * INTEGER TESTS * *****************/ // Note that integer comparison is just int1-int2 (or a variation therein) PrintIntegers(const array[], size) { for (new i=0; i f2) { return -1; } else if (f1 < f2) { return 1; } return 0; } public Action:Command_TestSort1D(args) { new Float:array[10] = {6.3, 7.6, 3.2, 2.1, 8.5, 5.2, 0.4, 1.7, 4.8, 8.2} SortCustom1D(_:array, 10, Custom1DSort) PrintFloats(array, 10) return Plugin_Handled } /*************************** * String comparison tests * ***************************/ PrintStrings(const String:array[][], size) { for (new i=0; i