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

Allow custom sorter function for getSortedRowIds #190

Open
brandondrew opened this issue Oct 23, 2024 · 4 comments
Open

Allow custom sorter function for getSortedRowIds #190

brandondrew opened this issue Oct 23, 2024 · 4 comments
Labels
enhancement New feature or request pull requests welcome Would love help with this!

Comments

@brandondrew
Copy link

Describe the bug

  1. Navigate to https://codepen.io/pen?editors=0110
  2. Click on the "id" column until it is sorted in ascending order
  3. Notice that it is not a numeric sort

Your Example Website or App

https://codepen.io/pen?editors=0110

Steps to Reproduce the Bug or Issue

  1. Navigate to https://codepen.io/pen?editors=0110
  2. Click on the "id" column until it is sorted in ascending order
  3. Notice that it is not a numeric sort

Expected behavior

Integers should be sorted as integers.

Screenshots or Videos

image

Platform

  • OS: macOS
  • Browser: Sidekick (Chrome)
  • Version: 124.61.1.50292 (Official Build) (arm64)

Additional context

No response

@waynesbrain
Copy link

waynesbrain commented Oct 24, 2024

@brandondrew I couldn't load your codepen and I have confirmed that I can load other codepens. Your link just shows a blank environment. (Maybe you have to publish it.)

@jamesgpearce
Copy link
Contributor

It's this demo: https://tinybase.org/demos/ui-components/sortedtableinhtmltable (and I think @brandondrew launched it into CodePen).

Ids everywhere in TinyBase are strings so this is the correct ordering. Where numbers have been used for them (as in the case of the movie demo) it does look weird.

One API improvement this suggests is to add a custom sorter function to the getSortedRowIds method so that the default sort can be overridden. Changing issue title accordingly!

@jamesgpearce jamesgpearce changed the title Demo Bug: sorting is not numeric in ID columns Allow custom sorter function for getSortedRowIds Oct 27, 2024
@jamesgpearce jamesgpearce added enhancement New feature or request pull requests welcome Would love help with this! labels Oct 27, 2024
@brandondrew
Copy link
Author

Okay, sorry if this is a dumb questions, but is there a reason for IDs to be strings?

@jamesgpearce
Copy link
Contributor

Well that's not a stupid question! It has just been an 'opinion' used in the design of TinyBase, and to ensure that there isn't confusion between types. (You can have a string representation of a number, but not a number representation of a string)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pull requests welcome Would love help with this!
Projects
None yet
Development

No branches or pull requests

3 participants