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

Refine "Sort Blocks by Category" operation #1583

Closed
ewpatton opened this issue Mar 2, 2019 · 7 comments
Closed

Refine "Sort Blocks by Category" operation #1583

ewpatton opened this issue Mar 2, 2019 · 7 comments

Comments

@ewpatton
Copy link
Member

ewpatton commented Mar 2, 2019

The "Sort Blocks by Category" menu item doesn't really do what its name implies. Most blocks are sorted by category, yes, except for procedure and component blocks, which they are sorted by name, and except for any-component blocks, which are all "Component" for the purposes of sorting.

I propose that we refine the sorting algorithm to do the following:

  1. Global defs first, lexicographically sorted
  2. Procedure defs next, lexicographically sorted
  3. Component event handlers, lexicographically sorted by type name, instance name, then event name
  4. Other free-floating blocks, sorted by category then block type. For component blocks, they should be sorted internally first by type, whether they are generic (generics precede specifics), then by instance name (for specific blocks), then by method/property name.

If this is implemented after #1548 is merged, I propose that any component event handlers, sorted by type then event name, precede all specific event handlers (step 2.5).

@halatmit
Copy link
Contributor

halatmit commented Mar 2, 2019 via email

@xueyuanw
Copy link
Contributor

xueyuanw commented Mar 9, 2019

I would like to take a look at this issue!

@ewpatton
Copy link
Member Author

ewpatton commented Mar 9, 2019

@xueyuanw It’s all yours.

@xueyuanw
Copy link
Contributor

xueyuanw commented Mar 9, 2019

May I know what files I should look into? Thanks!

@ewpatton
Copy link
Member Author

@xueyuanw The logic for sorting by category is defined on line 627 of blocklyeditor/src/workspace_svg.js

@ewpatton
Copy link
Member Author

Another subtlety here that we should consider is when ordering by component name, if the component names end with numerals, we might want to sort those numerical rather than lexicographically, e.g., Button10 should sort after Buttons 2-9, not before.

@ewpatton
Copy link
Member Author

Implemented by #1612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants