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)

26th Nov 2020, 2:17 PM
AmrulFY
AmrulFY - avatar
6 odpowiedzi
+ 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
26th Nov 2020, 5:16 PM
Flash
+ 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!
26th Nov 2020, 2:43 PM
Ipang
+ 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 ++
26th Nov 2020, 2:58 PM
AmrulFY
AmrulFY - avatar
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
26th Nov 2020, 3:18 PM
Ipang
0
Flash thanks bro
27th Nov 2020, 7:57 AM
AmrulFY
AmrulFY - avatar
27th Nov 2020, 8:05 AM
AmrulFY
AmrulFY - avatar