SL_SortListFunc


NAME
SL_SortListFunc -- sort a list with a user supplied compare function.

SYNOPSIS
SL_SortListFunc(list, function);
A0 A1

SL_SortListFunc(LISTHANDLE, WORD (*)(void *, void *));

FUNCTION
Sorts the supplied list using the supplied compare function to
determine sort order.

The function returns:
<0 if the first node is less than the second node
=0 if the first node is equal to the second node
>0 if the first node is greater than the second node

This return scheme is the same as the standard C function strcmp().

INPUTS

list - a LISTHANDLE as returned by SL_CreateListA.
func - a pointer to the compare function.

NOTE
The function argument must be declared using SL_CALLBACK.

EXAMPLE
SL_SortListFunc(list, &sortbyname);

SL_CALLBACK WORD sortbyname(void *n1, void *n2)
{
return(2);
}

SEE ALSO
SL_AddNodeAfter, SL_AddNodeBefore, SL_AddNodeHead, SL_AddNodeSorted, SL_AddNodeSortedFunc, SL_AddNodeTail, SL_ClearList, SL_CountNodes, SL_CreateListA, SL_CreateNodeA, SL_FindNodeFunc, SL_FindNodeName, SL_FindNodePos, SL_FindNodeUserData, SL_FirstNode, SL_FreeList, SL_FreeNode, SL_GetListAttr, SL_GetNodeAttr, SL_IsListEmpty, SL_LastNode, SL_NextNode, SL_PrevNode, SL_RemoveNode, SL_RemoveNodeHead, SL_RemoveNodeTail, SL_SetListAttrA, SL_SetNodeAttrA, SL_SortList, SL_SortListField, SL_SortListFieldRange, SL_SortListFunc, SL_SortListFuncRange, SL_SortListRange.

1. WORD)strcmp((SLCHAR *)SL_GetNodeAttr(n1, NODEATTR_Name), (SLCHAR *)SL_GetNodeAttr(n2, NODEATTR_Name

2. SLCHAR *)SL_GetNodeAttr(n1, NODEATTR_Name), (SLCHAR *)SL_GetNodeAttr(n2, NODEATTR_Name'>1</a>

 

SL_SortListFunc  Command Section By Type  url:SL_SortListFunc
  created:2008-03-01 23:36:29   last updated:2008-03-01 23:36:29
  Copyright © 1985-2024 GrasshopperLLC. All Rights Reserved.

User Contributed Comments For SL_SortListFunc
There are no user contributed comments for this page.