Skip to content

Commit

Permalink
Simplify mutable order
Browse files Browse the repository at this point in the history
  • Loading branch information
bokner committed Jan 9, 2025
1 parent 3541802 commit 143aa38
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/utils/mutable_order.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ defmodule CPSolver.Utils.MutableOrder do
values
|> Enum.with_index()
|> Enum.sort()
|> Enum.with_index()
|> Enum.sort_by(fn {{_val, sorted_idx}, _pos} -> sorted_idx end)
|> Enum.reduce(0, fn {{_val, sorted_idx}, pos}, pos_acc ->
array_update(value_positions_ref, pos_acc, pos)
array_update(sort_index_ref, pos, sorted_idx)
|> Enum.reduce(0, fn {_val, idx}, pos_acc ->
array_update(sort_index_ref, pos_acc, idx)
array_update(value_positions_ref, idx, pos_acc)
pos_acc + 1
end)

Expand Down

0 comments on commit 143aa38

Please sign in to comment.