C
C#3y ago
Mastalt

❔ Sort a list

how would sorting a list of object[] work with this:
outputResults.Sort((a, b) => a.CompareTo(b));
outputResults.Sort((a, b) => a.CompareTo(b));
4 Replies
CoffeeZombie
CoffeeZombie3y ago
Depends on what the sort rules are for the data types of a and b.
CoffeeZombie
CoffeeZombie3y ago
I'm a little unclear about what you're asking. This may give a little more detail: https://stackoverflow.com/questions/925471/sorting-a-list-of-objects-in-c-sharp
Stack Overflow
Sorting a List of objects in C#
public class CarSpecs { public String CarName { get; set; } public String CarMaker { get; set; } public DateTime CreationDate { get; set; } } This is a list and I am trying to figure out an
CoffeeZombie
CoffeeZombie3y ago
This gives another perspective on writing a custom comparer that you can use when sorting a list of Object https://www.geeksforgeeks.org/how-to-sort-object-array-by-specific-property-in-c-sharp/
GeeksforGeeks
How to Sort Object Array By Specific Property in C#? - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server