0

How can I bubblesort strings?

Hello guys! I need to make a program that takes 10 names along with surnames in a 2d array. How can I sort it (bubblesort) using as a criteria the surnames? By now I can only do it using the first names.

27th Apr 2019, 4:38 PM
MargaritaK
6 odpowiedzi
0
see i don't know about any other language but as far as c++ is concerned what you can do is make an array of pairs in each pair save surname as pair.first and name as pair.second then simple do the sort function on the array and you are done
27th Apr 2019, 5:15 PM
bruh bruh
0
Kushagra Gupta There is the whitespace factor that I have to think about and I have to start the sorting after the whitespace and according to the 1st letter of the surname
27th Apr 2019, 5:17 PM
MargaritaK
0
Ani Jona 🕊 yes the name and the lastname are separated already, and it has to be a bubblesort. I am trying to count the ascii number of the first name and add 32 that is the ascii number of the whitespace and start the bubblesort from these indexes for each name but it doesn't work...
27th Apr 2019, 5:49 PM
MargaritaK
0
Ani Jona 🕊 I see your point, it's ok, thank you for answering🙂
27th Apr 2019, 6:04 PM
MargaritaK
27th Apr 2019, 6:24 PM
MargaritaK
0
Ani Jona 🕊 oh I see, thank you very much for your help, I'll go through it again and check it🙂
27th Apr 2019, 7:53 PM
MargaritaK