Csharp: I am trying to get the top nth values from and rectangular array
Posted
by user355925
on Stack Overflow
See other posts from Stack Overflow
or by user355925
Published on 2010-06-01T22:42:27Z
Indexed on
2010/06/01
22:43 UTC
Read the original article
Hit count: 193
c#
I am reading a txt file for strings that represent intergers. the file is space delimited. I have created an array[10,2]. evertime the 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.
ie 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
© Stack Overflow or respective owner