-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Add sort in memory to Arrays library
#4846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d78ae17
Migrate 'arrays'
RenanSouza2 52b3bd8
fix findUpperBound and add findLowerBound
Amxx 9a1411b
add memory variants
Amxx c4726c8
Merge branch 'master' into feature/array-bound-with-duplicates
Amxx a6ec616
fix merge
Amxx 23e8db9
fix lint
Amxx c72591f
minimize change
Amxx 9162e42
add changeset
Amxx ed1de5b
Apply suggestions from code review
Amxx 4c1c7f4
add Arrays.sort
Amxx abd07b6
add sort test
Amxx 1e89815
fix lint
Amxx b73989d
codespell
Amxx 79bf367
add fuzzing tests for Arrays.sort
Amxx f2d49ef
add unsafeMemoryAccess tests
Amxx c043453
Merge branch 'master' into feature/quicksort
Amxx c75de32
fix lint
Amxx f823bee
lint
Amxx c90f12b
Update contracts/utils/Arrays.sol
Amxx 180a969
Update contracts/utils/Arrays.sol
Amxx 708972f
Apply suggestions from code review
Amxx 533e6cd
Merge branch 'master' into feature/quicksort
Amxx 3f1f0a5
Update contracts/utils/Arrays.sol
ernestognw 5a0ad7f
Add comments to `_quickSort`
ernestognw a8e6f54
Lint
ernestognw 7600291
Update contracts/utils/Arrays.sol
Amxx 6f163d2
Update contracts/utils/Arrays.sol
Amxx 8983066
cache the pivot and improve doc
Amxx 8704763
Apply suggestions from code review
Amxx 4336e2e
Merge branch 'master' into feature/quicksort
Amxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'openzeppelin-solidity': minor | ||
| --- | ||
|
|
||
| `Arrays`: add a `sort` function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {Test} from "forge-std/Test.sol"; | ||
| import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol"; | ||
|
|
||
| contract ArraysTest is Test { | ||
| function testSort(uint256[] memory values) public { | ||
| Arrays.sort(values); | ||
| for (uint256 i = 1; i < values.length; ++i) { | ||
| assertLe(values[i - 1], values[i]); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.