What does happen when you get two identical dates?

As you don't say anything about the context, supposing unix-like, I thought I could mention various one-liners to get a feeling of your data:

  • UN*X golf. It is always worth playing with your system sort as it is often optimized for speed.
  • a Minimal Perl approach.
  • % steph@apexPDell2 (/home/stephan/t) % % cat data.txt # I added the last line + item group entry_date 34 gr1 2003-03-02 12 gr1 1990-03-14 39 gr3 2002-04-11 66 gr4 2006-03-16 32 gr3 1998-02-13 90 gr1 2004-06-15 55 gr4 1999-06-15 10 gr1 2003-03-02 % steph@apexPDell2 (/home/stephan/t) % % LC_ALL=C sort -k 3 data.txt | perl -lna -e 'print if $F[1] eq q{gr1} + and $F[0] == 34' 34 gr1 2003-03-02 % steph@apexPDell2 (/home/stephan/t) % % sort -k 3 data.txt | grep gr1 | sort -n | head -n1 10 gr1 2003-03-02

    The last one reads as sort on the date, select group gr1, select on the first numerically and keep tghe first line. In this particular case it is faster to grep first.

    cheers --stephan

    In reply to Re: Pulling out oldest entries from a text file by sgt
    in thread Pulling out oldest entries from a text file by Angharad

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.