Skip to content
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

Add Sorting Blocks to JSON Extension #728

Closed
wants to merge 4 commits into from
Closed

Add Sorting Blocks to JSON Extension #728

wants to merge 4 commits into from

Conversation

WeirdBoi12408
Copy link

@WeirdBoi12408 WeirdBoi12408 commented Jul 12, 2023

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

image

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.
image

If the input is an object, it will convert all the values to the specified type.
image

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.
image

If the JSON input only contains numbers, it will be sorted numerically.
image

IF the JSON input contains anything other than a number, it will be sorted alphanumerically.
image

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.
image

If the input is an object, it will discard the keys and grade based on the values.
image

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.
image

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.
image

If you want to sort a list numerically then mix some list blocks with the sorting blocks.
image

@Skyhigh173
Copy link
Contributor

great! however there's two JSON extension poll about sorting.

@WeirdBoi12408
Copy link
Author

yeah ik i just decided to create a pull request here because lily thought that i should also submit it

@WeirdBoi12408
Copy link
Author

oops i messed up one of the pictures please ignore the nested grades one

@GarboMuffin
Copy link
Member

The sorting part of this was made redundant by #723

We can add the other blocks if you rebase this on master

@WeirdBoi12408 WeirdBoi12408 closed this by deleting the head repository Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants