[英]c# tuple list multiple sort in order
我有一個這樣的元組列表: List<Tuple<int, char, string> ws= new List<Tuple<int, char,string>>();
我得到 output 像這樣:
7 'S': And on silentious porpoises, whose snouts
6 'E': One eats one pate, even of salt, quotha.
6 'I': Of snails, musician of pears, principium
6 'T': It was not so much the lost terrestrial,
6 'E': Berries of villages, a barber's eye,
5 'E': The sovereign ghost. As such, the Socrates
5 'A': The snug hibernal from that sea and salt,
5 'E': Preceptor to the sea? Crispin at sea
5 'I': Nota: man is the intelligence of his soil,
5 'E': An eye most apt in gelatines and jupes,
但我想 output 喜歡:
7 'S': And on silentious porpoises, whose snouts
6 'E': Berries of villages, a barber's eye,
6 'T': It was not so much the lost terrestrial,
6 'I': Of snails, musician of pears, principium
6 'E': One eats one pate, even of salt, quotha.
6 'S': The sovereign ghost. As such, the Socrates
5 'E': An eye most apt in gelatines and jupes,
5 'I': Nota: man is the intelligence of his soil,
5 'O': On porpoises, instead of apricots,
5 'E': Preceptor to the sea? Crispin at sea
因此,以某種方式與 item 1 以降序排列,並且 item1 等於 item3 以升序排列。
你可以這樣做:
ws.OrderByDescending(i => i.Item1).ThenBy(i => i.Item3)
它實際上不會更改列表,但您可以在想要 output 項目的位置使用它。
在這里看到它:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.