Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

sortcar

sortcar( 
l_data 
u_comparefn 
) 
=> l_result

Description

Similar to sort except that only the car of each element in a list is used for comparison by the sort function. This function does not create a new list. It returns the altered input list.

This function also sorts l_data based on the function u_comparefn.

The l_data list is modified in place and no new storage is allocated. Pointers previously pointing to l_data might not be pointing at the head of the sorted list.

Arguments

l_data

List of objects to be sorted.

u_comparefn

Comparison function to determine which of any two elements should come first.

Value Returned

l_result

l_data sorted by the comparison function u_comparefn.

Examples

sortcar( '((4 four) (3 three) (2 two)) 'lessp )
=> ((2 two) (3 three) (4 four)
sortcar( '((d 4) (b 2) (c 3) (a 1)) nil )
=> ((a 1) (b 2) (c 3) (d 4))
myList = list('(2 two) '(4 four) '(1 one) '(3 three))
newList = sortcar( copy(myList) 'lessp )
newList = ((1 one) (2 two) (3 three) (4 four))
myList = ((2 two) (4 four) (1 one) (3 three)) ;; not changed !!

Related Topics

sort


Return to top
 ⠀
X