0
Sorting Struct in Function
How can i make the data in a struct can be sorted based on one data, with various types of data? And also how can I create that function and then call it without being randomized (one data represents all)
6 Réponses
+ 2
you can’t sort struct like that; however, you can sort the container of that struct with any data member of that struct given that you can compare that data member. e.g.
https://code.sololearn.com/cxpwEM7K1BzJ/?ref=app
+ 1
Are you asking about sorting array of structs? I had to ask because as per my understanding struct members are not sortable, and even if possible, it doesn't make sense to be.
It was unclear what you meant by
"sorted based on one data, with various types of data"
"without being randomized (one data represents all)"
If possible, please rephrase the Description, adding a language name in tags, an illustration e.g. the data to be processed, being unsorted and sorted. Hopefully it helps the community to understand your situation, and assist you effectively and efficiently.
Good luck!
+ 1
Yeah, I mean sorting the data records in the struct. If it's not possible, what should I do to create sortable data record without struct? Especially in C ++
0
Can you at least tell me what data you are working on? I'm like a blind man here with so little information given from you.
Do you have a copy of the code here in SoloLearn? maybe it helps to describe the idea better if you can share the code link for an inspection. Just follow the guide below to share it, in case you didn't know how.
https://www.sololearn.com/post/75089/?ref=app
0
Flash thanks bro
0
Ipang This is my code
https://code.sololearn.com/c8qIt8tQhTU8/?ref=app