3 ways to Sort in Descending order via lambdas(www.ginktage.com)

submitted by isenthilisenthil(2304) 8 months, 15 days ago

3 ways to Sort in Descending order via lambdas In C# , one can sort the List of Objects using Lambdas easily . Until now , i found the LINQ Query to be more easy to sort but after using the Lamba expression , i feel that the lambda expression can also be used effectively to sort in descending order . For example , i use the below class for the datapublic class Movie { public string MovieName { get; set; } public string Actor { get; set; } }

3 comments |category: |Views: 34

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by dpetersondpeterson(4397) 8 months, 13 days ago 0

Normally I wouldn't consider sorting a very interesting topic, but I honestly did not know about using the minus symbol in lambda expressions. That's very handy.

I do still feel that the linq order by statement is more descriptive (and easier for maintenance programmers to understand), but having the ability to use the lambda equivalent can make for more succinct code.

Reply

posted by RobertTheGreyRobertTheGrey(447) 8 months, 13 days ago 0

That last one is particularly scary - simply swapping the x and y gives you descending order. Imagine when some comes to debug that just can't figure out why it's descending just because it's not intuitive at all :) I can see many heads bashing brick walls because of that. I'll probably still stick to Reverse() or OrderByDescending with proper Linq :)

Reply

posted by isenthilisenthil(2304) 8 months, 13 days ago 0

yes . you are right . But its good that i learnt that something like this existed )

Reply

information Login or create an account to comment on this story