- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist to wonder why this cluster wasn't replaced by a SortedDictionary type?
Admin
select frist from comments order desc
Admin
var comment = CommentItems.OrderBy(x => x.Key).FristOrDefault();
Admin
This is honestly the first time a DWTF has actually exploded my head. I had to re-read the code four or five times to make sure I hadn't missed some spark of genius of something. It hurts!!
Admin
Yeah, as @LCrawford noted, C# even has this specific SortedDictionary type built in. And has for as long as I've been using .NET, going back at least to version 2.0. But if you're not retrieving them sorted often then normal dict + OrderBy will make your inserts faster.
Tradeoffs! ... at least if you even know what your options are in the first place.
Admin
you use the word "actually". I don't think it means what you think it means. Or please supply us with a screenshot of you typing a comment with an exploded head. On second thought, that would be gross.
Admin
I literally laughed my head off.
Admin
You use the word "screenshot". I don't think it means what you (actually) think it means. :D
Admin
Sorry for your loss
Admin
The data is supposed to be placed in a specific order, not just by title. It was able to be replaced with a list of mediaItem objects. Instead of keeping track of indices etc, you can just create a list with all of the items in the proper order. If you'll note from GetResultsWithSort, all it's doing is creating a list, sorted by the index passed in to AddRootItemWithSort
Admin
The object placed in Dictionary<string, object>["Sections"] is in fact an IEnumerable, not a materialized list.