INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Sort 2d histogram data smallest to largest

## Sort 2d histogram data smallest to largest

(OP)
I've got 2D histogram data output

6.5 -1.25 10.2804
6.5404 -1.25 10.4907
6.58081 -1.25 10.8087
6.62121 -1.25 10.4686
6.66162 -1.25 10.506
6.70202 -1.25 10.3084
6.74242 -1.25 9.68256
6.78283 -1.25 9.41229
6.82323 -1.25 9.43078
6.86364 -1.25 9.62408
6.90404 -1.25 9.23871
6.94444 -1.25 9.4298
6.98485 -1.25 9.42173
7.02525 -1.25 9.45413
7.06566 -1.25 9.2722
...
6.5 -1.21717 10.3285
6.5404 -1.21717 11.1678
6.58081 -1.21717 10.8977
6.62121 -1.21717 10.8864
6.66162 -1.21717 10.3389
6.70202 -1.21717 9.96492
6.74242 -1.21717 10.4141
6.78283 -1.21717 10.1318

I need to sort the data in both X and Y column simultaneously, to get ordered pairs (X,Y) from smallest to largest.

sort -k1,1n -k2,2n inputdata.dat
did not work

### RE: Sort 2d histogram data smallest to largest

how should the result (for the data above) look like ?

### RE: Sort 2d histogram data smallest to largest

(OP)
It should be min(X,Y) to max(X,Y)

6.5 -1.25 10.2804
6.5 -1.21717 10.3285
etc

No value must decrease in subsequent records. I need the data in R which requires incremantal X, Y ordering.

### RE: Sort 2d histogram data smallest to largest

(OP)
Currently the data decreases in periodic repetition

6.5 -1.25 10.2804
6.5404 -1.25 10.4907
6.58081 -1.25 10.8087
6.62121 -1.25 10.4686
6.66162 -1.25 10.506
6.70202 -1.25 10.3084
6.74242 -1.25 9.68256
6.78283 -1.25 9.41229
6.82323 -1.25 9.43078
6.86364 -1.25 9.62408
6.90404 -1.25 9.23871
6.94444 -1.25 9.4298
6.98485 -1.25 9.42173
7.02525 -1.25 9.45413
7.06566 -1.25 9.2722
...
6.5 -1.21717 10.3285
6.5404 -1.21717 11.1678
6.58081 -1.21717 10.8977

6.62121 -1.21717 10.8864
6.66162 -1.21717 10.3389
6.70202 -1.21717 9.96492
6.74242 -1.21717 10.4141
6.78283 -1.21717 10.1318

I need to sort simultaneously X and Y to get rid of this order.

### RE: Sort 2d histogram data smallest to largest

I tried:

#### CODE

$export LC_ALL=C$ sort -k1 -k2 -n inputdata 

and got the data sorted:

#### CODE

6.5 -1.25 10.2804
6.5 -1.21717 10.3285
6.5404 -1.25 10.4907
6.5404 -1.21717 11.1678
6.58081 -1.25 10.8087
6.58081 -1.21717 10.8977
6.62121 -1.25 10.4686
6.62121 -1.21717 10.8864
6.66162 -1.25 10.506
6.66162 -1.21717 10.3389
6.70202 -1.25 10.3084
6.70202 -1.21717 9.96492
6.74242 -1.25 9.68256
6.74242 -1.21717 10.4141
6.78283 -1.25 9.41229
6.78283 -1.21717 10.1318
6.82323 -1.25 9.43078
6.86364 -1.25 9.62408
6.90404 -1.25 9.23871
6.94444 -1.25 9.4298
6.98485 -1.25 9.42173
7.02525 -1.25 9.45413
7.06566 -1.25 9.2722 

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!