The solutions provided by igelkott both produce the same output for the example input data:
2 - 1 1 1 1 1 1 - 1 1 1 2 8 1 - 1 5 6 12 12

However, this output does not conform to the example output given by the OP:
2 - 1 1 1 1 1 1 - 1 2 1 1 8 1 - 1 6 5 12 12

The following code produces output that seems to conform to the OP's exemplified requirement (the two added values of '0 0 0 0 0' test for proper handling of leading-zero removal):

2 - 0 0 0 0 0 2 - 1 1 1 1 1 1 - 1 2 1 1 8 1 - 1 6 5 12 12

Code:

use warnings; use strict; my @AllPatterns = ( '1 2 1 1 8', '0 0 0 0 0', '1 6 5 12 12', '0 0 0 0 0', '1 1 1 1 1', '1 1 1 1 1', ); { # limit scope of array processing variables my $biggest = 10; # biggest number (most decimal digits) my $fmt = join ' ', ("%0${biggest}ld") x 5; my $lead0s = qr{ \b 0{1,@{[ $biggest - 1 ]}} }xms; my %seen; # unique-ifing hash @AllPatterns = # 7. save to original array map { "$seen{$_} - $_" } # 6. make into final format grep { not $seen{$_}++ } # 5. only patterns not seen yet map { s{$lead0s}{}xmsg; $_ } # 4. remove padding sort # 3. lexicographic ascending sort # map { print "'$_' \n"; $_ } # 2b. FOR DEBUG map { sprintf $fmt, split } # 2. pad fields to constant widths @AllPatterns # 1. for all patterns... ; } # end scope of array processing variables print join("\n", @AllPatterns), "\n";

In reply to Re: Need to sort large table of data... by Anonymous Monk
in thread Need to sort large table of data... by fiddler42

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.