Get the top nth values from a rectangular array
- by user355925
I am reading a txt file for strings that represent integers. The file is space delimited. I have created an array[10,2]. Everytime the strings 1~10 is found in the file I increment array[n,0] by 1. I also feed array[n,1] with numbers 1~10.
i.e. txt file contents:
1/1/1 10/1/2001 1 1 10 2 2 3 1 5 10 word word 3 3 etc..
streamreader reads 1/1/1 and determines that is is not 1~10
streamreader reads 10/1/2001 and determines that it is not 1~10
streamreader reads 1 and ++array[0,0]
streamreader reads 1 and ++array[0,0]
streamreader reads 10 and ++array[9,0]
etc..
The result will be:
'1' was found 3 times
'2' was found 2 times
'3' was found 3 times
'5' was found 1 time
'10' was found 2 times
My problem is that I need this array placed in order(sorted) by value of column 0
so that it would be:
1
3
2
10
5