forge install grappafinance/array-lib@v0.1.0 --no-commit
Add to remapping.txt
array-lib=lib/array-lib/src
import {UintArrayLib} from "array-lib/UintArrayLib.sol";
using UintArrayLib for uint256[];
function zeroSum(uint256[] memory arr) internal pure returns (bool) {
return arr.sum() == 0;
}
import {QuickSort} from "array-lib/sorting/QuickSort.sol";
using QuickSort for uint256[];
function calculateSomethingHard() internal pure returns (bool) {
uint256[] memory arr = _getArr();
// get a new sorting array
uint256[] sorted = arr.getSorted();
// sort in memory
arr.sort();
}