A brain freeze question on sort?

From: BobMCT
Sent on: Monday, July 23, 2012 9:00 PM
Hello Luggers,

I hope someone is reading these.

I am trying to sort a simple file into order of alphamerically by the 
first field and numerically by the second field witin.  The fields are 
separated by a space.

Here is a snippet of my data:

$_address1 1006
$_address1 1079
$_address1 1080
$_address1 1214
$_address1 1228
$_address1 45
$_address1 716
$_address1 747
$_address1 748
$_address1 842
$_address2 1007
$_address2 1085
$_address2 1214
$_address2 1229
$_address2 46
$_address2 717
$_address2 753
$_address2 842

And as you can see the 2nd field appears to be random within the first. 
  I've tried numerous tricks with sort such as:

-g to get numeric sorting (but that didn't work because it expects the 
number to be in characters 1+

-n to force a numeric sort but again that worked like the -g

-k 1.1,2.1  to define the 1st field as the first key starting in pos 1 
and the second field as the 2nd key starting in its relative position 1. 
  Both didn't work and gave me much the same output as above.  Then I 
added the letter n to the end of the 2nd field "-k 1.1,2.1n" and this 
didn't work at all.

I've ready tons of material on this today and tried virtually everything 
I found.  Can any of you luggers come up with some sound ideas?

Thanks all.  Bob

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy