Skip to content

Commit

Permalink
Sort only literals
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcardon committed Nov 18, 2024
1 parent 4ecd179 commit fe48319
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pact-repl/Pact/Core/IR/Eval/Direct/CoreBuiltin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,16 @@ rawSort info b _env = \case
chargeGasArgs info (GComparison (SortComparisons maxSize (V.length vli)))
vli' <- liftIO $ do
v' <- V.thaw vli
V.sort v'
V.sortBy sortPv v'
V.freeze v'
return (VList vli')
args -> argsError info b args
where
sortPv (PLiteral l) (PLiteral y) = l `compare` y
sortPv (PTime t) (PTime t') = t `compare` t'
sortPv (PLiteral _) (PTime _) = LT
sortPv (PTime _) (PLiteral _) = GT
sortPv _ _ = EQ

coreRemove :: (IsBuiltin b) => NativeFunction e b i
coreRemove info b _env = \case
Expand Down
8 changes: 7 additions & 1 deletion pact/Pact/Core/IR/Eval/CEK/CoreBuiltin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,16 @@ rawSort info b cont handler _env = \case
chargeGasArgs info (GComparison (SortComparisons maxSize (V.length vli)))
vli' <- liftIO $ do
v' <- V.thaw vli
V.sort v'
V.sortBy sortPv v'
V.freeze v'
returnCEKValue cont handler (VList vli')
args -> argsError info b args
where
sortPv (PLiteral l) (PLiteral y) = l `compare` y
sortPv (PTime t) (PTime t') = t `compare` t'
sortPv (PLiteral _) (PTime _) = LT
sortPv (PTime _) (PLiteral _) = GT
sortPv _ _ = EQ

coreRemove :: (IsBuiltin b) => NativeFunction e b i
coreRemove info b cont handler _env = \case
Expand Down

0 comments on commit fe48319

Please sign in to comment.