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

Adding dot separator #20

Closed
AlainPilon opened this issue Jan 16, 2024 · 7 comments · Fixed by #21
Closed

Adding dot separator #20

AlainPilon opened this issue Jan 16, 2024 · 7 comments · Fixed by #21
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@AlainPilon
Copy link

Hi. Could you add the "." (dot) to the list of separators.

Thanks

@sgryjp
Copy link
Owner

sgryjp commented Jan 20, 2024

Hi. Could you show me how you plan to use this feature?

I’m concerned that simply adding . as a separator might be difficult because Smart Sort supports sorting CSV fields that often contain numbers with decimal points (e.g., 3.14). If you could tell me more about your use case, I could consider a more flexible approach.

@AlainPilon
Copy link
Author

This requirement comes from wanting to sort css classes when using haml markup.

Ex:

.text-center.pt-12
  %h1.mb-4.text-4xl.tracking-tight.font-bold.text-gray-900.dark:text-white
    = @user.name

In the sample above, I would like to be able to sort .mb-4.text-4xl.tracking-tight.font-bold.text-gray-900.dark:text-white as sorting classes is a Tailwind best practice.

Also note that it is possible in haml to not define the html tag (instead it will use a div by default), ex:

.mb-4.font-medium
  = @user.last_name

@sgryjp
Copy link
Owner

sgryjp commented Jan 21, 2024

@AlainPilon Thank you for clarification! Now I understand your request.

I think trying to use dot as a separator only if no whitespace characters are selected is acceptable. Do you think this behavior is acceptable?

Background of the design

For example, let's think the example illustrated below:

.modal .warning.button, .modal .button.danger { ... }
\___________________________________________/
  |    \_____________/  \___________________/
  |      |                |
  |      +-- Range B      +-- Range A
  +-- RANGE C

Current Smart Sort (1.2.1) will choose separator as next: comma for range C, space for range A and B. After adding the dot as separator as described above, Smart Sort will choose separator as: comma for range C, space for B, and dot for A.

@AlainPilon
Copy link
Author

I think trying to use dot as a separator only if no whitespace characters are selected is acceptable. Do you think this behaviour is acceptable?

Totally.

Another option, to protect other users from unexpected sort, would be to have the dot separator sorting as an option (false by default).

@sgryjp sgryjp self-assigned this Jan 28, 2024
@sgryjp sgryjp added the enhancement New feature or request label Jan 28, 2024
@sgryjp sgryjp closed this as completed in #21 Feb 3, 2024
@sgryjp sgryjp added this to the v1.3.0 milestone Feb 3, 2024
@sgryjp
Copy link
Owner

sgryjp commented Feb 3, 2024

@AlainPilon Hi, I just released version 1.3.0 which includes the feature.

I decided to make the feature on by default (can opt-out too) because it should no be a surprise change as previous version of Smart Sort did nothing under the condition to execute the new feature.

Please try it and if you notice anything, please let me know. Thank you!

@AlainPilon
Copy link
Author

Cool! I am working on everything but front end code these days. But as soon as I am, I will test it right away! Thx!

@AlainPilon
Copy link
Author

Just to circle back on this after working with it for a few days: so far everything works perfectly. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants