In this C Programming example, we will implement the program to sort characters in a string in ascending alphabetical order and print the output on the console.
Table of Contents
1. Sort characters in a string – Selection Sort
To sort characters in a string in ascending alphabetical order, we will first iterate over the characters and then compare two characters at a time. If in case the characters are not found in the correct order then we will swap the characters using a temporary variable and repeat the process until we reach null character(or no more characters are left for comparison) and then print the output on the console.
This process of sorting is also known as Selection sort. Please refer to Selection Sorting for details.
Helpful topics to understand this program better are-