linq - in C#, how do I order items in a list where the "largest" values are in the middle of the list -
I've been stumped for a while. I would like to take a list in the list so that the list of the biggest value products in the middle of the list is finished. And I also want to do the opposite, that is, make sure the items end up with the highest price on the outer boundaries of the list.
Imagine a data structure like this .. 1,2,3, 4,5,6,7,8,9,10
In the first scenario, , 5,7,9,10,8,6,4,2 is needed to get back. Another scenario requires me to get back 10,8,6,4,2,1,3,5,7,9
The list may contain items above 250, the numbers will not be distributed evenly, and they will not be sequential, and I wanted to reduce the copy numbers would be included in the product objects, More ordinary In will not integer.
Is there a simple solution that I am not seeing?
Any ideas.
So whatever you are thinking of, what I am doing, I am ordering items based on the calculation font size. Here is the code I went to ...
Implementation ...
Private zero reader (var tempList = new LinkedList & lt; DisplayTag & gt; (); Bull also = true; Leading (various tags in this) {if (even) tempList.AddLast (tag); Other tempList.AddFirst (tag); Even even =! } This.Clear (); This.AddRange (tempList); }
Test ...
[testseagord (lowestest, result = new [] {10,14,18,22, 26, 30}}} [] [Test Seed (Ligst Teasmelst, Result = New [] (30,26,22,18,14,10}) [Test Sees (Disclaimer Order: Larsest in the Middle, Result = New [] (Test, date, maximum, ultimate result = new [] (30, 22, 14, 10, 18, 26})] [Public Sections] [10] (18, 26, 30, 22, 14} ] Calculate fontasio_order tigs_appprography (disks) Plate order sort order) {list.CloudOrder = sortOrder; list.CalculateFontSize (); Var result = (choose displayTag.FontSize in the list from displayTag) .ToArray (); Returning result;}
Use ...
Public Zero CalculateFontSize () {GetMaximumRange (); GetMinimunRange (); CalculateDelta (); This.ForEach ((displayTag) => Calculate fontTags (displayTag); OrderByFontSize ();} Private Zero Commandbephon Fontsis () {Switch (Cloud Order) {Case Display Order. Minimum Largest: This. Sign (arg1, arg2) => Arg1.FontSize.CompareTo (arg2.FontSize)); break; Case display order. Largest TOS lowest minimum: this Sir (new Large First Compaion ()); break; Case display order. Legest in the middle: this. Contents (New Largest Compactor ()); Reorder (); break; Case display order. Lambeston Diuus: It. head (); Reorder (); break; }}
The proper data structure is a linkeded list
Allows you to efficiently eliminate either:
linked list & lt; Int & gt; Results = New Linkedist & lt; Int & gt; (); Int [] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Array.Sort (array); Bull Weird = True; Foreach (array in var x) {if (strange) result. Adlace (x); And the result. Adfist (X); Weird =! strange; } Foreach (result in int item) Console.Write ("{0}", item);
No additional copy steps, no step back, just ... for just a small overhead to store the node.
Comments
Post a Comment