Previous Thread
Next Thread
Print Thread
Rate Thread
#103296 11/17/2001 4:39 AM
Joined: Dec 2000
Posts: 595
Member
Member
Offline
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 smile

Sponsored Links
#103297 11/17/2001 5:43 AM
Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
I guess there is a better way, but try:
Code
code:

#103298 11/17/2001 6:05 AM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
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
#103299 11/17/2001 8:16 AM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
spaceship operator? laugh

Using it in a sub is better I think;
Code
code:

#103300 11/17/2001 9:01 AM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
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 smile

Yes, spaceship operator is how a lot of people in the perl community refer to <=> since it looks like a spaceship smile


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
Sponsored Links
#103301 11/17/2001 12:11 PM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
Quote
quote:
well.. you can call this sub from another file and use it in every sub, just as a shortcut smile

IMO ...

#103302 11/17/2001 12:53 PM
Joined: Dec 2000
Posts: 730
deutscher moderator / v5 specialist
deutscher moderator / v5 specialist
Offline
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... [Linked Image]

I have used following code for the testing:
Code
code:
Following is shown:
Code
code:
[Linked Image]


----
translate with Web.de

[ 11-17-2001: Message edited by: joking-down ]

#103303 11/17/2001 1:58 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
Quote
quote:
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

smile


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#103304 11/17/2001 1:59 PM
Joined: Dec 2000
Posts: 595
Member
Member
Offline
Joined: Dec 2000
Posts: 595
thanks guys, thanks Mark.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
Ruben Rocha
Ruben Rocha
Lutz,FL,USA
Posts: 253
Joined: January 2000
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 2265
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 27
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)