0

How do you arrange the names in alphabetical language c++?

11th Jun 2021, 1:35 PM
mohamed alkasem
mohamed alkasem - avatar
7 Answers
+ 3
محمد القاسم , it seems that we need some more information from you. ▪︎how are these names stored: in an array, in a list, in a dictionary? ▪︎should the sorting be in ascending or in descending order? ▪︎what about the handling of lowercase / uppercase letters? ▪︎are you allowed to use library to do the sorting, or do you have to implement an exising sorting algorithm to do the job? ▪︎??? as we can see in your profile, you have not started any tutorial in sololearn until now. this could mean, that you are just start in coding? may be it can help you to work through the c++ tutorial. if you are just asking that someone will do the job for you: we can help you, but you should have done a try by yourself first. please show us your attempt. it would be great if you could rework your question. thanks!
11th Jun 2021, 1:44 PM
Lothar
Lothar - avatar
+ 3
You could compare character by character and use one of the normal sorting methods (bubble sort, insertion sort) OR use the built-in C++ Standard Library function, sort(). Add a third parameter in that to sort based on character values (note the upper-case, lower-case thing here) Obviously, keep in mind the questions asked by Lothar.
11th Jun 2021, 1:47 PM
Nikhil
Nikhil - avatar
+ 3
Lothar Ah, yeah I agree with all that. I somehow assumed their knowledge on the topic. Mistake there. Anyway, I'll be removing the solution, thanks for reminding! ^^
11th Jun 2021, 2:01 PM
Nikhil
Nikhil - avatar
+ 2
Nikhil , you are showing a really nice code to help someone solving a task. we all appreciate this very much!  (this is my personal statement - but it is not to criticize someone !!) but there is an issue by giving a ready solution, when the op has not done and shown his attempt first. as a part of the community i belive that learning by doing is more helpful, than just using a shared solution. we should act more as a mentor.  it is a very successful way when we are giving hints and help, so that the op is able to solve his task by himself. it would be great if you are going to help us to keep sololearn what it is: ▪︎a unique place to learn (we are a "self" learning platform!) ▪︎an absolutely great community that is willing to help other people  ▪︎a great resource of people which has an unbelievable knowledge in coding and a long lasting experience ▪︎a place to meet people and to discuss with them all the possible points of view thanks for your understanding Thanks for your understanding.
11th Jun 2021, 1:55 PM
Lothar
Lothar - avatar
+ 2
Nikhil , I created an employee record that includes a name of type Strings and an address of type integer Create a partial function to enter information Now in the main function, I want to arrange the names of the employees alphabetically and print them. can I use (srtcmp)?
11th Jun 2021, 2:55 PM
mohamed alkasem
mohamed alkasem - avatar
+ 2
Thanks guys I solved this with a bubble. (ASCII table)
12th Jun 2021, 2:36 PM
mohamed alkasem
mohamed alkasem - avatar
+ 1
Use string array then for loop with condition statement which refers to the first character. Then use bubble sorting. You have also declare temporary variable because you need it when sorting.
12th Jun 2021, 7:17 AM
TeaserCode