how to pass an array to function and return array in asedning order
i want to make programme in c# ,how to pass an array to function and return array in asedning order .
Re: how to pass an array to function and return array in asedning order
Instead of using a raw array, why not use a generic list collection? Then you can call .Sort() to sort the collection.
Of course, if this is a homework assignment, then you'll have to do it manually.
Re: how to pass an array to function and return array in asedning order
Alternatively you can use LINQ to sort the array. IMO its the better choice because of its flexibility. You can specify a function for it to use in a transformation. Basically, you can tell it how to derive values from each element of whatever type is in the array and sort on that.
Code:
//
int[] numbers=new int[]{90,1,87,78,2,3,12};
numbers = numbers.OrderBy(i => i).ToArray();
Note that you must be targeting the .Net Framework 3.5 and up to use LINQ.