3 * =============================================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
34 #if defined _sorting_included
37 #define _sorting_included
40 * Contains sorting orders.
44 Sort_Ascending = 0, /**< Ascending order */
45 Sort_Descending = 1, /**< Descending order */
49 * Sorts an array of integers.
51 * @param array Array of integers to sort in-place.
52 * @param array_size Size of the array.
53 * @param order Sorting order to use.
56 native SortIntegers(array[], array_size, SortOrder:order = Sort_Ascending);
59 * Sorts an array of float point numbers.
61 * @param array Array of floating point numbers to sort in-place.
62 * @param array_size Size of the array.
63 * @param order Sorting order to use.
66 native SortFloats(Float:array[], array_size, SortOrder:order = Sort_Ascending);
69 * Sorts an array of strings.
71 * @param array Array of strings to sort in-place.
72 * @param array_size Size of the array.
73 * @param order Sorting order to use.
76 native SortStrings(String:array[][], num_strings, SortOrder:order = Sort_Ascending);
79 * Sort comparison function for 1D array elements.
80 * @note You may need to use explicit tags in order to use data properly.
82 * @param elem1 First element to compare.
83 * @param elem2 Second element to compare.
84 * @param array Array that is being sorted (order is undefined).
85 * @param hndl Handle optionally passed in while sorting.
86 * @return -1 if first should go before second
87 * 0 if first is equal to second
88 * 1 if first should go after second
90 functag SortFunc1D public(elem1, elem2, const array[], Handle:hndl);
93 * Sorts a custom 1D array. You must pass in a comparison function.
95 * @param array Array to sort.
96 * @param array_size Size of the array to sort.
97 * @param sortfunc Sort function.
98 * @param hndl Optional Handle to pass through the comparison calls.
101 native SortCustom1D(array[], array_size, SortFunc1D:sortfunc, Handle:hndl=INVALID_HANDLE);
104 * Sort comparison function for 2D array elements (sub-arrays).
105 * @note You may need to use explicit tags in order to use data properly.
107 * @param elem1 First array to compare.
108 * @param elem2 Second array to compare.
109 * @param array Array that is being sorted (order is undefined).
110 * @param hndl Handle optionally passed in while sorting.
111 * @return -1 if first should go before second
112 * 0 if first is equal to second
113 * 1 if first should go after second
117 public(array[], array[], const array[][], Handle:hndl),
118 public(String:array[], String:array[], const String:array[][], Handle:hndl),
122 * Sorts a custom 2D array. You must pass in a comparison function.
124 * @param array Array to sort.
125 * @param array_size Size of the major array to sort (first index, outermost).
126 * @param sortfunc Sort comparison function to use.
127 * @param hndl Optional Handle to pass through the comparison calls.
130 native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);