> In Perl you can do it with 3 lines of code. Consider the example
> below:
>
>
> #!/usr/bin/perl -w
> use strict;
>
> my @testset = ( 'A'..'Z' );
> push @testset, ( 'AA'..'ZZ' );
>
> for ( sort @testset ) {
> print "DEFAULT ORDERING: $_\n";
> }
>
> for ( sort { length($a) <=> length($b)
> ||
> $a cmp $b } @testset ) {
> print "ORDERING USER DEFINED: $_\n";
> }
This should work:
select * from mytable order by length(myfield),myfield;