Ahn210
Technical User
- Jun 18, 2013
- 11
Hello,
I'm a newbie to fortran and need some help on sorting 2 columns of data (related) to be sorted on 1 column.
For instance, if my input text file has following:
ID nums
12 0.111
58 1.52
101 0.5
10 2.89
I declared 2 single array ID) and nums)
and applied selection sort on nums)
DO J = 1, 9
DO K = J+1, 10
IF(nums(J) > nums(K)) THEN
temp = nums(K)
nums(K) = nums(J)
nums(J) = temp
END IF
END DO
END DO
result was it only sorted on nums and misaligned data with ID....
How can I sort for following outcome?
ID nums
101 0.5
12 0.111
58 1.52
10 2.89
Thank you!
I'm a newbie to fortran and need some help on sorting 2 columns of data (related) to be sorted on 1 column.
For instance, if my input text file has following:
ID nums
12 0.111
58 1.52
101 0.5
10 2.89
I declared 2 single array ID) and nums)
and applied selection sort on nums)
DO J = 1, 9
DO K = J+1, 10
IF(nums(J) > nums(K)) THEN
temp = nums(K)
nums(K) = nums(J)
nums(J) = temp
END IF
END DO
END DO
result was it only sorted on nums and misaligned data with ID....
How can I sort for following outcome?
ID nums
101 0.5
12 0.111
58 1.52
10 2.89
Thank you!