Sort a String Alphabetically in C – Case-Sensitive and Case-Insensitive

To sort a string alphabetically in C, apply bubble sort to the character array: compare adjacent characters and swap them when the left character is greater than the right. After all passes, the characters are in ascending ASCII order — digits first, then uppercase A–Z, then lowercase a–z. For a sort that treats ‘A’ and …

C Program to Sort Names in Alphabetical Order (Bubble Sort)

Sorting names alphabetically in C means sorting an array of strings — and that’s what makes this program a classic: you can’t compare strings with > or swap them with =. You need strcmp() to compare and strcpy() to swap, and that pair of ideas is exactly what this exercise teaches. This version reads N …