Sort Variables in C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sort Variables in C#

Hi everyone, my problem is quite complex. I want to sort airplanes, based on the time each one needs to fly a certain distance. Lets say the user set the distance to 5000km. The program will now calculate the time for every plane. After that process I have one variable for each plane that contains the time. Now I want sort the planes, so I can display the planes, based on the time they need. So the fastest plane should be the first one, the second fastest plane should be the second one, and so on. I know its really complicated, but I hope some of you might have an answer/suggestion. I happy to answer your questions, should you have any. :-)

6th Feb 2020, 9:35 PM
ExampleWasTaken
ExampleWasTaken - avatar
2 Answers
+ 3
Hey bro, you must Create airplan class with some properties like name, time and... And then add them to list, after that use linq to sort data Use this code https://code.sololearn.com/cLOe9g9h3KVm/?ref=app
20th Feb 2020, 9:19 PM
hossein B
hossein B - avatar
0
Thank you very much for your answer. But when I put them into a list, I am not able to keep track, which value corresponds to which aircraft. For example, plane 1 needs 1 hour, and plane 2 needs 1:15 hours. When I convert it into a list, I loose the plane. I have the values sorted, but I do not know anymore, which plane needs 1h and which 1:15h. Is there a way to link the two information together?
7th Feb 2020, 12:04 PM
ExampleWasTaken
ExampleWasTaken - avatar