in reply to Sorting SQL results

If you want to sort the keys of the hash numerically, tell Perl to do so:
print F $row_ref->{$_} for sort { $a <=> $b } keys %$row_ref;

Sorry, you want to print the userid first. Just do

print F $row_ref->{$_} for qw(userid giftid);
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Sorting SQL results
by nickt9999 (Acolyte) on Oct 11, 2013 at 18:03 UTC

    Sorry was typing my reply as you corrected yours.

    I cannot use :

    print F $row_ref->{$_} for qw(userid giftid);

    as the column names will be dynamic based on what table I query.

    Is there a way to order they by how they query returns them?

      fetchrow_arrayref works.