VecSort

Table of Contents

VecSort

Description

Sort given vector with given comparator using quicksort algorithm.

Parameters

NameDirectionDescription
vin,outVector to be sorted.
compareinCompare function. Signature and behaviour must be similar to that of ZstrCompare.

Success

return

Failure

Does not return

Usage example (Cross-references)

    // Test VecSort function
    bool test_vec_sort(void) {
    printf("Testing VecSort\n");
    
    // Create a vector of integers
    
    // Sort the vector in ascending order
    VecSort(&vec, compare_ints_asc);
    
    // Check that the elements are sorted
    
    // Sort the vector in descending order
    VecSort(&vec, compare_ints_desc);
    
    // Check that the elements are sorted in descending order

Share :