Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting A vs AA

Status
Not open for further replies.

ibjdt

Programmer
Nov 25, 2002
63
i have a database of technical drawing info including the revision level of the drawing.

the revisions go A, B, C...Z then AA...AZ, BA...BZ, and so on.
if i sort the db by rev letter as follows:

Code:
     @rev = sort {
     (split '::', $a, 5)[1] cmp
     (split '::', $b, 5)[1]
     ||
     (split '::', $a, 5)[0] cmp
     (split '::', $b, 5)[0]
     } @rev;

**[1] is rev letter / [0] is another bit of data

the result is A, AA, B, BA, etc.

how can i get A, B, C...Z, AA, AB...AZ, BA...BZ, etc.

thanks.
 
Code:
@rev = sort { length($a) <=> length($b) || $a cmp $b } @rev;

Enjoy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top