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.
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
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
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...
0
Ani Jona 🕊 I see your point, it's ok, thank you for answering🙂
0
Ani Jona 🕊 thank you very much! Here's my code
https://code.sololearn.com/cO6aE2CXB5rE/?ref=app
0
Ani Jona 🕊 oh I see, thank you very much for your help, I'll go through it again and check it🙂