Sorting confusion



Hi all,

I'm having a problem using 'sort' to pre-process log files. I'm not
getting my output sorted as I expect:

Given an input set:

2007-12-04 20:33:10.587532 "35:1196800053:389002" a
2007-12-04 20:30:25.384069 "35:1196800053:389002" b
2007-12-04 20:33:25.384069 "25:1196800053:389002" c

(fields are date, time, session id, something else)

I want to sort by the session id then by the time:

sort -t \t -k 3,3 -k 1,2 <test
2007-12-04 20:30:25.384069 "35:1196800053:389002" b
2007-12-04 20:33:10.587532 "35:1196800053:389002" a
2007-12-04 20:33:25.384069 "25:1196800053:389002" c

I would expect the last entry to be first ("25...<"35...) instead
output seems to sorted on k2.

It not due to sort getting confused about the order of keys:

sort -t \t -k 3,3 <test
2007-12-04 20:30:25.384069 "35:1196800053:389002" b
2007-12-04 20:33:10.587532 "35:1196800053:389002" a
2007-12-04 20:33:25.384069 "25:1196800053:389002" c

lowest session id still comes last.

sort --version reports:
sort (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the
terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and Paul Eggert.

I've tried stripping the quotes around the session id to no avail. If
the session id comes in the first column it works OK.

I expect I'm doing something stoopid, but I can't for the life of me
see what.

(yes the seperators are all tabs).

Help!

C.
.



Relevant Pages

  • Re: Sorting confusion
    ... I'm having a problem using 'sort' to pre-process log files. ... I want to sort by the session id then by the time: ... Copyright 2006 Free Software Foundation, ... the session id comes in the first column it works OK. ...
    (uk.comp.os.linux)
  • Re: Ascending/Descending
    ... can't see why, if you pull out the fields that you want into the query grid, ... sort ascending on the fields, ... want to sort by session & signal in others you say session & frequency .. ... Sort: Ascending Ascending ...
    (microsoft.public.access.queries)
  • Re: Thanks Joel for informing the FDA about LYMErix
    ... Loon...got news for you...that sort of public comment session is ... usually reserved for the appearance of public input. ...
    (sci.med.diseases.lyme)
  • Re: Where to place server code to invoke when client page closes.
    ... code the Telephony-server proxy object is already "null". ... should invoke a method of the Telephony Server. ... pass it some sort of argument? ... identifier representing the login object which I stored as a Session ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Ascending/Descending
    ... bit confused here - if you put sort ascending on both fields with sessionid ... to the left of signal field i can't see why it's sorting so strangley, ... > I had a look and the Session ID field is to the left of ... >>Hi Nick ...
    (microsoft.public.access.queries)