From d1d70f4ad540f4d57d1b577b337b6db38074e223 Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Tue, 26 Mar 2019 09:54:10 +0100 Subject: [PATCH] OrderController Sortierung berichtigt. Sort::Naturally hat auch nicht wie erwartet sortiert --- SL/Controller/Order.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 656883c07..c37dc1c94 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -910,9 +910,17 @@ sub action_reorder_items { my $method = $sort_keys{$::form->{order_by}}; my @to_sort = map { { old_pos => $_->position, order_by => $method->($_) } } @{ $self->order->items_sorted }; if ($::form->{sort_dir}) { - @to_sort = sort { Sort::Naturally::ncmp($a->{order_by}, $b->{order_by} ) } @to_sort; + if ( $::form->{order_by} =~ m/qty|sellprice|discount/ ){ + @to_sort = sort { $a->{order_by} <=> $b->{order_by} } @to_sort; + } else { + @to_sort = sort { $a->{order_by} cmp $b->{order_by} } @to_sort; + } } else { - @to_sort = sort { Sort::Naturally::ncmp($b->{order_by}, $a->{order_by} ) } @to_sort; + if ( $::form->{order_by} =~ m/qty|sellprice|discount/ ){ + @to_sort = sort { $b->{order_by} <=> $a->{order_by} } @to_sort; + } else { + @to_sort = sort { $b->{order_by} cmp $a->{order_by} } @to_sort; + } } $self->js ->run('kivi.Order.redisplay_items', \@to_sort) -- 2.20.1