The keys will come out of the hash in an arbitrary order. So you can either:
$SQL = "select userid a, giftid b ...."; . . . print F "$row_ref->{$_} " for sort keys %$row_ref;
print F "$row_rf->{$_} for qw( userid gifid );
while ($row_ref = $ST->fetchrow_arrayref) { print F "$row_ref->[$i] " for 0 .. $#{$row_ref};
By the way, that could be written better as:
print F join(" ", @$row_ref);
Update: changed keys to columns in first bullet point; Added while statement part to the third to illustrate fetchrow_arrayref.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Sorting SQL results
by roboticus
in thread Sorting SQL results
by nickt9999
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |