Add Sorting Blocks to JSON Extension #728
Closed
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.
Edit:
This extension update was rejected due because it wasn't linted. The extension is taken down and it will only be for personal use now.
New Blocks
Convert all values in ( ) to ( )
This block will convert all the values in an object or items in an array to a specified type.
If the input is an array, it will simply convert all the items to the specified type.
If the input is an object, it will convert all the values to the specified type.
Sort JSON ( ) in ( ) order
This block sorts a JSON in numerical or alphanumerical order depending on its items / values.
If the input is an array, it will be sorted. If the input is an object, it will be sorted and only the keys will be returned.
If the JSON input only contains numbers, it will be sorted numerically.
IF the JSON input contains anything other than a number, it will be sorted alphanumerically.
Grade JSON ( ) in ( ) order
This block will return the indices of the array / object as if it were sorted.
If the input is an array, it will grade it normally.
If the input is an object, it will discard the keys and grade based on the values.
note: This block is equivalent to the monadic
⍋
and⍒
functions in APL.Useful block combinations
If you want to sort a list of stringified numbers and want to sort them numerically, you can convert them to a Number type before sorting.
If you want to do the opposite of a grade (for each index return where it moves) then simply put a grade inside of a grade.
If you want to sort a list numerically then mix some list blocks with the sorting blocks.