ordered.txt

my $products  = $schema->resultset('Products')->search;
my @new_order = get_order(); # 3,5,1,2,4,6

$schema->txn_do(sub {
    while(my $row = $products->next) {
        my $pos = shift @new_order;

        if($row->ordered == $pos) {
            next;
        }

        my $check = $schema->resultset('Products')->search({ordered => $pos});

        if(my $tmp = $check->next) {
            $tmp->move_to(undef);
        }

        $row->move_to( $pos );
        $row->update;
    }

});