|
-
December 14th, 2010, 08:25 AM
#1
[RESOLVED] Sorting a Generic List
1st > Not using Forms!
so I have a class called Label that draws text on a screen - and no this is not Windows Forms!
I have a Party and that Party has an inventory, like items, weapons and stuff. I have a GUI screen where the inventory is displayed like so
Code:
Weapons Equipped / Count
Bow 1/2
Dagger 1/1
Mace 0/3
Sword 2/4
so on the far left is a List<Labels> and on the far right is another List<Labels>
I gave the Label class a property called name, that way Label Bow, Bow.Name = Bow
since the other Label 1/2 needs to be paired with Label Bow, that Label.Name also = Bow
Here is the problem, depending on how the Labels are added to the List, they may be displayed improperly, especially on the Labels that are just a bunch of numbers like 2/4, so I need to Sort them alphabetically by their Label.Name inside the List<Label>
and... I don't know how to do that
I tried to use
Code:
Sort(Comparison<T> comparison);
but I don't know how that works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|