Sort the Numbers Ascending/Descending using LINQ

This code Snippets help you to Sort the Numbers with Ascending or Descending Using LINQ

Array of Numbers


Dim numbers() = {1, 2, 8, 5, 3, 3, 3, 3, 5, 3, 89, 9}


Sorted Descending..


'Collection of Descending Numbers
Dim DescendingNumbers = From mynumber In numbers Order By mynumber Descending



Sorted Ascending


'Collection of Ascending Numbers
Dim AscendingNumbers = From mynumber In numbers Order By mynumber Ascending


Descending Duplicates Removed



'Descending Numbers without Duplicate
Dim DescendingNumbersWithoutDuplicate = From mynumber In numbers Order By mynumber Descending.Distinct().ToArray


Ascending with Duplicates Removed


'Ascending Numbers without duplicate
Dim AscendingNumbersWithoutDuplicate = From mynumber In numbers Order By mynumber Ascending.Distinct.ToArray()


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: