Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option 1
- line a
- line b
- line c
- option 3
- line x
- line z
- line y
- option 2
- a1
- a4
- a2
- a3
- option 1
- line a
- line b
- line c
- option 2
- a1
- a2
- a3
- a4
- option 3
- line x
- line y
- line z
- static IEnumerable<string> Sort(IEnumerable<string> unsorted)
- {
- string option = null;
- return
- from line in unsorted
- let isSubitem = line.StartsWith(" ")
- let parent = isSubitem ? option : option = line
- orderby parent, isSubitem, line
- select line;
- }
- static IEnumerable<string> Sort(IEnumerable<string> unsorted)
- {
- string option = null;
- return
- unsorted
- .OrderBy(line => line.StartsWith(" ") ? option : option = line)
- .ThenBy(line => line.StartsWith(" ") ? line : null);
- }
- yourEnumerable.OrderBy(y => y.Key).ThenBy(y => y.Prop2)
- string lineRead;
- string current;
- var dictionary = new Dictionary<string, List<string>>);
- while((lineRead = reader.ReadLine())
- {
- if(!lineRead.StartsWith(" "))
- {
- dictionary.Add(lineRead, new List<string>());
- current = lineRead;
- }
- else
- {
- dictionary[current].Add(lineRead);
- }
- }
- dictionary.Keys.ToList().ForEach(y => dictionary[y] = dictionary[y].OrderBy(x => x).ToList());
- dictionary.OrderBy(y => y.Key);
- .OrderBy(x => x.option)
- .ThenBy(x=>x.secondary)
- list.OrderBy(<a delegate that will sort your array>).ThenBy(<a delegate that will sort your array again>)
Add Comment
Please, Sign In to add comment