Descending sort

J

Jürgen Exner

Colossus wrote:
[...]
Bah, people are really stupid !

Oh yes, they are!

PROUD TO PLONK
Life's too short to be trolled, spammed or get upset about lame
posters! Make the Net a better place by ignoring those who annoy you.
Don't be annoyed; keep your calm. Be proud to plonk.

On the brink of doing just that.

However, if you are not a troll and you are honestly confused, then you may
want to read http://www.catb.org/~esr/faqs/smart-questions.html .
While that page has little to do with Perl, it may explain to you why your
expectations and behaviour clashes with the established customs in technical
newsgroups.

jue
 
A

Anno Siegel

Colossus said:
I'm not an expert in programming but I'm humble and eagier to
learn more and more by asking the help of others and that's why
I posted the question. Unfortunately on this newsgroups as in the worls

Aha. It's all this newsgroup's (and the world's) fault.
there are very proud person like you and the others who replied me (apart
Michele Dondi) who feel authorized to mistreat beginners like me only
because they are "expert" in programming, that is all. I just asked
help because I was not able to accomplish the problem neither reading
the perldoc -f sort neither reading "Perl documentation". It is not a fault
to grab a piece of code written by others,

Not at all. However, blindly applying code to a situation it was never
meant for isn't going to do you much good. Complaining, in that situation,
that the code is broken is a sign of either inexperience or stupidity.

You did that twice in this thread.
but you and the others with your
proud answers mean just that. Just a counsel to you and the others who
replied me: don' start useless flames, but please be useful for others: if
you know the solution to their problem answer them otherwise don't do it.

Useful, eh?

My answer was useful (as were the answers of others) and did solve
your problem, as far as you ever stated it. You ripped it apart and
misapplied it.

I don't know what you mean by "proud", but Usenet isn't known for mincing
words. If you are easily offended, better get your advice elsewhere.
If you want respect, earn it. You don't do that by offending the people
who are trying to help you.

Anno
 
A

Anno Siegel

Colossus said:
I think that the obvious things are very difficult to understand. From my
example is very clear that I want to sort from the last field in descending
sort.

Talk about proud answers.

Your example makes *nothing* clear. As has been discussed in this thread,
the result can be derived from the original through sorting by columns 1
and 5, or by columns 3 and 5. Are you reading the thread at all?

Anno
 
C

Colossus

Bernard said:
What on earth are you babbling about? You're gonna get your ass
mistreated by me right now, but you sure as hell weren't mistreated
before.
http://www.albion.com/netiquette/corerules.html

Do you consider example code mistreatment?

Do you consider a suggestion to read the documentation for a function you
don't understand mistreatment?

Do you consider a plea for a better problem description which would help
us help you mistreatment?
Do you consider well meant advice to not use code you don't understand
mistreatment?

Neither of this, you did undertstand nothing of the thread.
You were advised not to use code you don't understand. Either understand
it or write your own. Perfectly sound advice. What's your problem with
it?

Neither my friend. You are arising this problem.
You weren't flamed a single time in this thread.

Matter of opinion as far as I see.
You were *asked* for
things, but you weren't flamed. In fact, *you* called several people here
*stupid* for the sole reason that they didn't provide you with an answer
for your "simple problem".

Quote the message where I wrote so. I never said this. You are a flamer
and maybe also a troll. I called stupid those who arises useless flames.
These people tried to provide an answer to a
poorly worded problem

poorly worded ? I gave a perfect example of the expected output, infact Mr
Tore Aursand understood perfectly, so my message was clear.
and in reward are called "stupid"

No, no. Again I called stupid those who arise flames, not those who kindly
replies to the newbie. I solved the problem thanks to the answers of the
repliers but what a pity that to have the solution a flame has been
arised !
by someone who in ten years will still have less knowledge of Perl than
they had ten years ago. That's abominable.

Who tells you ? Are you a prophet beyond being the lawyer of the newsgroup ?
Seems to me like you're the "stupid" one around here.
I do not arise flames.
 
T

Tore Aursand

I think that the obvious things are very difficult to understand. From
my example is very clear that I want to sort from the last field in
descending sort.

First of all you don't say that in your post. Secondly, your example of
how you want the sorted data to be doesn't conform to the rule of sorting
the last column in a descending order.
I have a flat database file this way:

A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110

The fields are tab separated. I want it this way:
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39

As I hope you can see, the data _IS NOT_ sorted in a descending order.

Desperatly trying to humanly parse your data, I think the latter data is
sorted on column 3 (descending) and then on column 5 (descending).

And - again - you can use Sort::Fields for that. And - again - please
express yourself _much_ clearer next time you want _us_ to understand what
you _actually_ means.
 
C

Colossus

Anno said:
My answer was useful (as were the answers of others) and did solve
your problem, as far as you ever stated it. You ripped it apart and
misapplied it.

It's true. I solved the problem thanks to your code that works, I was
disappointed by the WAY you and others answered the thread that's why
I run in replying that your code doesn't work without applying it properly
as I did some hours later.
I don't know what you mean by "proud", but Usenet isn't known for mincing
words.

The meaning in the english language.
If you are easily offended, better get your advice elsewhere.

I will do it.
If you want respect, earn it. You don't do that by offending the people
who are trying to help you.

You helped me being harshly and proud in your answers, I felt offended.
Anyway you are right, I will get counsel elsewhere,

Thank you,
 
C

Colossus

Hi,

I realized that my example was not clear.
I apologize toward all who replied me. The problem
was mine. An alphabetical order was needed on first column.
Please accept my deepest apologizes.

I have appreciated the answers given by all of you,
in particular the one of Anno who solved my problem.
 
K

ko

[ snip scary rant :) ]
That's what they do day in and day out. They've been doing it for years
and I sure hope they don't stop anytime soon. The only thing they ask in
return for their freely shared expertise is that people who come here
looking for it adhere to some *very* simple rules which were created to
make helping beginners like you easier for everybody involved. Seems to
me like you're the "stupid" one around here.

Don't mean to offend, and in no way trying to imply that its not good to
have a good rant now and then :) - but really, its a waste of time on
someone who: (1) wants a spoon-fed answer, (2) whines incessantly when
they don't get that spoon-fed answer worded just they way they want it,
and (3) can't even see/acknowledge the fact that there just may be the
*possibly* that their problem wasn't presented clearly.

And although the OP doesn't get it, finding about Anno's Text::Table
module was good for me :) - there are so many text-related modules...

keith
 
P

Peter Hickman

Colossus said:
Tore Aursand wrote:




You are right.

Now you say. The best I could come up with was that it was sorted on column 1
(or 3) as text ascending and 5 as numbers descending. Which gives us the
following beginners code.

#!/usr/bin/perl

use strict;
use warnings;

my @biglist;

while(my $line = <DATA>) {
push(@biglist, [split('\t', $line)] );
}

my @newlist = sort {
$a->[0] cmp $b->[0]
or
$b->[4] <=> $a->[4]
} @biglist;

foreach my $line (@newlist) {
print join("\t", @{$line});
}


__DATA__
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110

Which gives:

A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
 
A

Anno Siegel

ko said:
[ snip scary rant :) ]
That's what they do day in and day out. They've been doing it for years
and I sure hope they don't stop anytime soon. The only thing they ask in
return for their freely shared expertise is that people who come here
looking for it adhere to some *very* simple rules which were created to
make helping beginners like you easier for everybody involved. Seems to
me like you're the "stupid" one around here.

Don't mean to offend, and in no way trying to imply that its not good to
have a good rant now and then :) - but really, its a waste of time on
someone who: (1) wants a spoon-fed answer, (2) whines incessantly when
they don't get that spoon-fed answer worded just they way they want it,
and (3) can't even see/acknowledge the fact that there just may be the
*possibly* that their problem wasn't presented clearly.

Well, I think that these discussions do serve a purpose, besides
informing particular posters of the error of their ways (which indeed
often doesn't work). It is necessary, from time to time, to make sure
there is a rough consensus among the regulars and lurkers about what is
acceptable behavior and what isn't. These meta-threads help establish
that consensus.
And although the OP doesn't get it, finding about Anno's Text::Table
module was good for me :) - there are so many text-related modules...

That's why I plug it occasionally :)

Anno
 
A

Anno Siegel

ko said:
[ snip scary rant :) ]
That's what they do day in and day out. They've been doing it for years
and I sure hope they don't stop anytime soon. The only thing they ask in
return for their freely shared expertise is that people who come here
looking for it adhere to some *very* simple rules which were created to
make helping beginners like you easier for everybody involved. Seems to
me like you're the "stupid" one around here.

Don't mean to offend, and in no way trying to imply that its not good to
have a good rant now and then :) - but really, its a waste of time on
someone who: (1) wants a spoon-fed answer, (2) whines incessantly when
they don't get that spoon-fed answer worded just they way they want it,
and (3) can't even see/acknowledge the fact that there just may be the
*possibly* that their problem wasn't presented clearly.

Well, there were traces of insight recently.

I think that these discussions do serve a purpose, besides informing
particular posters of the error of their ways (which indeed often
doesn't work). It is necessary, from time to time, to make sure
there is a rough consensus among the regulars and lurkers about what
is acceptable behavior and what isn't. These meta-threads help
establish that consensus.
And although the OP doesn't get it, finding about Anno's Text::Table
module was good for me :) - there are so many text-related modules...

That's why I plug it occasionally :)

Anno
 
H

Helgi Briem

I realized that my example was not clear.
I apologize toward all who replied me. The problem
was mine. An alphabetical order was needed on first column.
Please accept my deepest apologizes.

I have appreciated the answers given by all of you,
in particular the one of Anno who solved my problem.

It's pretty late for that after having insulted almost
everyone who might have a shot at solving your
problem. Most of them have already killfiled you
and will never see anything you post, ever again.

Such is life.
 
C

Colossus

Helgi said:
It's pretty late for that after having insulted almost
everyone who might have a shot at solving your
problem.

My grandmother was used to tell me:
later is better than ever.
I had the humbleness to apologize, many others have not.
Most of them have already killfiled you
and will never see anything you post, ever again.

Who cares ? The world is a wheel who keeps turning. People
joines and leaves frequently the newsgroups. If I will post
again on this newsgroup others will surely reply me. Maybe you will
reply me one day...
 
B

Ben Morrow

Colossus said:
Ah ah ah ah ah ! That is very funny ! Programming must
be difficult otherwise it is not programming ? Ah ah ah ah ah !

No. Programming *is* difficult.

Particularly so if you do not have the right sort of mathematical/
logical intuition (though this is by no means to say that people who
do not cannot make perfectly good programmers: merely that they will
find it harder and less fun).

Ben
 
B

Ben Morrow

Colossus said:
My grandmother was used to tell me:
later is better than ever.

ITYM never?
I had the humbleness to apologize, many others have not.

Noone but you was in a position of needing to apologise, by the rules
of social interaction generally accepted in clpmisc. In case you are
unfamiliar with these, they include 'If you ask a stupid/unclear
question you must expect harsh words in response; you must not take
these to heart.'.

They also include 'Moralising is in general only acceptable from
regulars who have proved they have something of worth to contribute to
the group.'. (I realise I may be putting myself on the line here, but
I'll risk that... :)
Who cares ? The world is a wheel who keeps turning. People
joines and leaves frequently the newsgroups.

Useful, helpful and knowledgable people join relatively infrequently and
leave even less so.
If I will post again on this newsgroup others will surely reply
me.

These hypothetical 'others' are unlikely to be in a position to give
you as much useful help as Anno and the other regulars.

Bye...

Ben

[Good sigmonster! Here, have a cookie...]
 
M

Michele Dondi

A suitable starter might be

perldoc -f sort


What you call suitable is a very difficult
explanation on how to sort an array of more fields.

As I wrote in my other post, please quote correctly. I had to check
Gunnar Hjalmarsson's own post above to see what you consider a "very
difficult explanation"... and only now I realize that I gave you the
very same advice (but the 'perldoc -q' one is probably more
effective)!

However your claim is plainly false: the perldoc entry you were
pointed to definitely is *not* "an explanation on how to sort an array
of more fields", either difficult or not. It's the full documentation
of the sort() function, and certainly it is clear enough as to give
you an idea on how to sort an array "of more fields".

But then please explain what is difficult about 'perldoc -f sort' and
hopefully someone may help you with the difficulties you're
experiencing.


Ciao,
Michele
 
T

Tintin

poorly worded ? I gave a perfect example of the expected output, infact Mr
Tore Aursand understood perfectly, so my message was clear.

Tore only "understood" after you were repeatedly asked to clarify the output
and in the end you even admitted you were wrong (see below). I think you
owe everyone on this newsgroup an apology.
Tore Aursand wrote:

As I hope you can see, the data _IS NOT_ sorted in a descending order.

You are right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top