asp.net mvc 3 - Sort an array and return index of arrays according to elements size in c# -


i need sort array minimum maximum value, need return index of array after sorting it. dont want swap values, need return values index according value size, eg

int[] arr = {7,8,2,3,1,5}; (int i=0; i<=arr.length; i++) {    int index = array.indexof(arr, i); } 

now want return index of values minimum maximum 4,2,3,5,0,1.

your check in loop wrong should i < arr.length. index can do:

int[] arr = { 7, 8, 2, 3, 1, 5 }; int[] sortedindexarray = arr.select((r, i) => new { value = r, index = })                             .orderby(t => t.value)                             .select(p => p.index)                             .toarray(); 

for output:

foreach(int item in sortedindexarray)     console.writeline(item); 

output:

4 2 3 5 0 1 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -