diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 428bc16..8459dfc 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -113,7 +113,11 @@ sub new { $self->{instances_part_size} = 10_000_000; $self->adjust_partitions; - $self->{targets} = $self->{dbh}->selectall_arrayref("select * from filesets", { Slice => {} }); + # Order by ascending sort order with nulls last: + # MySQL considers NULL to be smaller than any number, so negate the numbers + # (making the largest the smallest) and then sort descending. + # Idea from https://www.designcise.com/web/tutorial/how-to-order-null-values-first-or-last-in-mysql + $self->{targets} = $self->{dbh}->selectall_arrayref("select * from filesets order by -sortorder desc", { Slice => {} }); if ($opt->{filesets}) { $self->{targets} = [