VOOZH about

URL: https://www.geeksforgeeks.org/dsa/c-program-sort-array-names-strings/

⇱ C Program to Sort an array of names or strings - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Sort an array of names or strings

Last Updated : 23 Jul, 2025

Given an array of strings in which all characters are of the same case, write a C function to sort them alphabetically.  The idea is to use qsort() in C and write a comparison function that uses strcmp() to compare two strings. 


Output
Given array is
0: geeksforgeeks 
1: geeksquiz 
2: clanguage 

Sorted array is
0: clanguage 
1: geeksforgeeks 
2: geeksquiz 

Time Complexity: O(nlogn)
Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: