+ 1

How to sort names in a file

So I'm making a project for a library with books ids and names I'm trying to sort them by name . Any help would be appreciated.

10th May 2020, 3:29 PM
PIZZA
PIZZA - avatar
1 Answer
+ 1
Okay, start from basics. ASSUMING WE HAVE BOOK WITH UNIQUE NAMES(and starting with different letters as well) Idk if u hav stored the book names in an array or where idk..but it u are working with arrays, U can iterate through the array elements and implement nested for loop to iterate through the alphabets and create a new array and store the first alphabet of first book in 0th location and do this for all the required books. Once done with it, what you hav is an array storing first letters of the book name. Then its just your wish on how u proceed. - bubble sort - selection sort - or any other way. Basic idea is grab a letter and loop through all the elements and sort accordingly IF YOU WANT I CAN EVEN SHOW YOU THE CODE WITH SOME EXAMPLE BOOK NAMES.
10th May 2020, 5:50 PM
Tejas Amit Sheth