OpShin / opshin

A simple pythonic programming language for Smart Contracts on Cardano
https://book.opshin.dev/
MIT License
141 stars 28 forks source link

Sort function when develop smartcontract #378

Closed thaopt closed 4 months ago

thaopt commented 4 months ago
thaopt commented 4 months ago

Please give me advice or sample if you have, thanks @nielstron Do you have any direct contact channel so i can contact you if faced any problem?

nielstron commented 4 months ago

I recommend you don't actually sort inside the validator (too expensive!) but expect the caller to pass in a sorted list. you can then just check that subsequent elements are <=

if you really want to sort, you need to implement something that works on immutable lists, i.e. not in-place like merge sort