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

Sort MethodAttr so that names starting with symbols are before names starting with alpha ASCII #1219

Merged
merged 1 commit into from
Nov 30, 2024

Conversation

flavorjones
Copy link
Contributor

There are three distinct ranges of symbols in ASCII:

  • the range below "A", 0..64 in decimal
  • the range between "Z" and "a", 91..96 in decimal
  • the range above "z", 123..127 in decimal

With this change, any method starting with a character in these "symbol ranges" will be sorted before a method starting with an alpha ASCII character. The remaining methods, all starting with alpha or 8-bit characters, will be sorted against each other exactly as before.

Specifically this addresses the issue from #1204 which is that #[] and #^ were previously sorted after the alpha methods. These methods will now be sorted before alpha methods.

Fixes #1204

There are three distinct ranges of symbols in ASCII:

- the range below "A", 0..64 in decimal
- the range between "Z" and "a", 91..96 in decimal
- the range above "z", 123..127 in decimal

With this change, any method starting with a character in these
"symbol ranges" will be sorted before a method starting with an alpha
ASCII character. The remaining methods, all starting with alpha or
8-bit characters, will be sorted against each other exactly as before.

Specifically this addresses the issue from ruby#1204 which is that `#[]`
and `#^` were previously sorted _after_ the alpha methods. These
methods will now be sorted before alpha methods.

Fixes ruby#1204
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm it fixes the issue. Thanks 👍

@@ -415,4 +415,16 @@ def to_s # :nodoc:
end
end

def name_codepoint_range # :nodoc:
case name.codepoints[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL codepoints

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case name.ord

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. See #1220

@st0012 st0012 merged commit a4f13d2 into ruby:master Nov 30, 2024
26 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Nov 30, 2024
(ruby/rdoc#1219)

There are three distinct ranges of symbols in ASCII:

- the range below "A", 0..64 in decimal
- the range between "Z" and "a", 91..96 in decimal
- the range above "z", 123..127 in decimal

With this change, any method starting with a character in these
"symbol ranges" will be sorted before a method starting with an alpha
ASCII character. The remaining methods, all starting with alpha or
8-bit characters, will be sorted against each other exactly as before.

Specifically this addresses the issue from #1204 which is that `#[]`
and `#^` were previously sorted _after_ the alpha methods. These
methods will now be sorted before alpha methods.

Fixes ruby/rdoc#1204

ruby/rdoc@a4f13d242b
@flavorjones flavorjones deleted the 1204-method-sort-for-symbols branch November 30, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Method names sorted by ASCII code causes ~ and | to be placed at the bottom
3 participants