Skip to content

Latest commit

 

History

History

Sorting Array of Strings

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

To sort a given array of strings into lexicographically increasing order or into an order in which the string with the lowest length appears first, a sorting function with a flag indicating the type of comparison strategy can be written. The disadvantage with doing so is having to rewrite the function for every new comparison strategy.
A better implementation would be to write a sorting function that accepts a pointer to the function that compares each pair of strings. Doing this will mean only passing a pointer to the sorting function with every new comparison strategy.
Given an array of strings, you need to implement a function which sorts the strings according to a comparison function, i.e, you need to implement the function :
void string_sort(const char *arr,const int cnt, int (cmp_func)(const char a, const char b)){

}








Sample Input 0


Sample Output 0