Overriding retrieve all for specific ordering

From ClassDBI

SUMMARY

By default, $class->retrieve_all will return a set of objects based on the order in the database. You can override it in your class file so that it is ordered by a specific column.

EXAMPLE

package Hosts;

__PACKAGE__->table("hosts");
__PACKAGE__->columns(All => qw/id name/);
__PACKAGE__->set_sql(RetrieveAll => <<);
 SELECT __ESSENTIAL__
 FROM   __TABLE__
 ORDER BY name

Now when a Hosts->retrieve_all is called, it will return a list of hosts, ordered by name.

ALTERNATIVE

You could also use Class::DBI::Plugin::RetrieveAll, which provides several methods for doing this.