instagram

Custom sorting algorithm

Base on given array of characters design your own sorting algorithm to sort array of string.

There will be two inputs as per below.

Input :
char a[] = { ‘z’, ‘q’, ‘a’, ‘s’, ‘d’, ‘y’, ‘c’ };
String s[] = { “zasd”, “qazyc”, “yczaq”, “caq”, “czq”, “dzaq”, “czqa”, “zzsd” };

Output: It will be sorted string array
String s[] = { “zzsd”, “zasd”, “qazyc”, “dzaq”, “yczaq”, “czq”, “czqa”, “caq” };

Algorithm :

Share