2
Answers

filtering and sorting array

filtering and sorting an array without using for/foreach loop.
use only array prototype methods. 
Answers (2)
1
Rajanikant Hawaldar

Rajanikant Hawaldar

31 38.8k 452.3k 5y
For filtering use lambda expressions
 
https://stackoverflow.com/questions/897466/filter-list-object-without-using-foreach-loop-in-c2-0 
 
Arrar sorting
 
https://www.geeksforgeeks.org/different-ways-to-sort-an-array-in-descending-order-in-c-sharp/ 
0
Mukesh Sagar

Mukesh Sagar

558 2.1k 27.3k 5y
For Filtering we can use the following methods:
 
Find() Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Array.
FindAll() Retrieves all the elements that match the conditions defined by the specified predicate.
FindIndex() Searches for an element that matches the conditions defined by a specified predicate, and returns the zero-based index of the first occurrence within an Array or a portion of it.
FindLast() Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire Array.
FindLastIndex() Searches for an element that matches the conditions defined by a specified predicate, and returns the zero-based index of the last occurrence within an Array or a portion of it.
LastIndexOf()
Returns the index of the last occurrence of a value in a one-dimensional Array or in a portion of the Array.
 
For Sorting an Array use the methods as :
 
Sort() Sorts the elements in a one-dimensional array.