ServerBrowserSort

GameSpy SDK

ServerBrowserSort

Sort the current list of servers.

void ServerBrowserSort(
ServerBrowser sb,
SBBool ascending,
gsi_char * sortkey,
SBCompareMode comparemode );
RoutineRequired HeaderDistribution
ServerBrowserSort<sb_serverbrowsing.h>SDKZIP

Parameters

sb
[in] ServerBrowser object intialized with ServerBrowserNew.
ascending
[in] When set to SBTrue this function will sort in ascending order. (a-b-c order, not c-b-a)
sortkey
[in] The "key" of the key/value pair to sort by.
comparemode
[in] Specifies the data type of the sortkey. See remarks.

Remarks

The ServerBrowserSort function will returned an ordered list of servers, sorted by the specified sortkey. Sorting may be in ascending or descending order and various data-types are supported. SBCompareMode may be one of the following values:

sbcm_int: Uses integer comparison. "1,2,3,12,15,20"

sbcm_float: Similar to above but considers decimal values. "1.1,1.2,2.1,3.0"

sbcm_strcase: Uses case sensitive string comparison. Uses strcmp.

sbcm_stricase: Case in-sensitive string comparision. Uses _stricmp or equivilent.

Please note that calling this function repeatedly for a large server list may impact performance. This is due to the standard qsort algorithm being ineffecient when sorting an already ordered list. This is rarely a cause for concern, but certain optimizations may be made if performance is noticeably impacted.

Unicode Mappings

RoutineGSI_UNICODE Not DefinedGSI_UNICODE Defined
ServerBrowserSortServerBrowserSortAServerBrowserSortW

ServerBrowserSortW and ServerBrowserSortA are UNICODE and ANSI mapped versions of ServerBrowserSort. The arguments of ServerBrowserSortA are ANSI strings; those of ServerBrowserSortW are wide-character strings.