Sorting a table made with Stacks.

how can i sort a table i made with stacks?

You’ll need to introduce State variables to store the current sort state, and then in your dynamic value that is repeating the row elements based on the data array, sort the array by according to that sort state.

For instance

  1. At a text state variable called sortfield
  2. Let’s say your objects have a field called title. Add an on-click handler to the column header that sets sortfield to title
  3. Edit your repetition dynamic value on the rows to loop over […myDataArray].sort((a,b) => a[$state.sortfield].localeCompare(b[$state.sortfield]))