Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Data managing problem

by BrowserUk (Patriarch)
on Feb 22, 2013 at 14:10 UTC ( [id://1020168]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Data managing problem
in thread Data managing problem

The printf is used to ensure that should the line numbers jump from single digit to two

The sprintf pads the lines numbers with leading zeros so the sort correctly. Ie so that they do not sort as:

1 10 11 ... 2 20 21 22 ... 3 30 31 32 33

%05u means we can correctly sort files with upto 99999 lines. If you need more change the number in the format.

Does the sort at the end assume that the input ( and the required output after removing rows ) is sorted

Why would sort "assume its input was sorted"? We are sorting them because we know they will not be. That's why we added the line numbers so that we can put the, back into the input ordering. Perhaps the following where I've left the line numbers in place will clarify things?

C:\test>perl -anle"$h{ $F[1] } = sprintf qq[%05u%s], $., $_; }{ print +for sort values %h" 1/2/2013 cgoo nreuiheru 1/4/2013 doow reiqrqueih 1/5/2013 hellio ruieqrhfuepqh 1/20/2013 cgoo 3rhquh4ureyh 1/30/2013 yetil jerqohgqrij 2/13/2013 hellio rueqipheruh 2/14/2013 cgoo wehrig4r74378 ^Z 000021/4/2013 doow reiqrqueih 000051/30/2013 yetil jerqohgqrij 000062/13/2013 hellio rueqipheruh 000072/14/2013 cgoo wehrig4r74378

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: Data managing problem
by tmharish (Friar) on Feb 22, 2013 at 14:17 UTC
    Why would sort "assume its input was sorted"?

    I assumed, incorrectly, that you were using the sorted nature of the dates ( and now realize that will not work anyway ... ) to get back the order the hashing messed up - but :

    Perhaps the following where I've left the line numbers in place will clarify things?

    Certainly does - Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1020168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-29 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found