|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
@array = sort (@array); range 0-30 this will sort 0, 10, 11, 12... 19, 1, 20, 21... id like to sort like this 1,2,3,4... thank you
|
|
|
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
Joined: Mar 2001
Posts: 7,394 |
I guess there is a better way, but try:
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
The proper way is to use the spaceship operator
sort {$a <=> $b} @array;
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: May 2000
Posts: 1,356
Addict
|
Addict
Joined: May 2000
Posts: 1,356 |
spaceship operator? Using it in a sub is better I think;
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
why? You're doing the exact same thing except adding a call to a subroutine overhead on top of it. Something like that, where the sub is nothing more than the command, is useless Yes, spaceship operator is how a lot of people in the perl community refer to <=> since it looks like a spaceship
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: May 2000
Posts: 1,356
Addict
|
Addict
Joined: May 2000
Posts: 1,356 |
well.. you can call this sub from another file and use it in every sub, just as a shortcut IMO ...
|
|
|
|
Joined: Dec 2000
Posts: 730
deutscher moderator / v5 specialist
|
deutscher moderator / v5 specialist
Joined: Dec 2000
Posts: 730 |
I don't know, as that participates under Unix, but the call of XX lasts with me, a Windows calculators, essentially longer... I have used following code for the testing: Following is shown: ---- translate with Web.de [ 11-17-2001: Message edited by: joking-down ]
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
But that's just it...it's a one line sort statement. You aren't saving anything by calling the sort directly, or calling a subroutine and still passing it the array. You're gaining the overhead of a subroutine call for no added benefit
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
thanks guys, thanks Mark.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 69
Joined: January 2001
|
|
Forums63
Topics37,573
Posts293,925
Members13,849
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|