question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to order by multiple columns

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

I don’t see a way to order by multiple columns. Here’s what I would do in SQL:

SELECT
	first_name,
	last_name
FROM
	customer
ORDER BY
	first_name ASC,
	last_name DESC;

Describe the solution you’d like

I’d like the order() method to accept multiple columns. Here’s an idea:

const { data, error } = await supabase
  .from('customer')
  .select('first_name', 'last_name')
  .order([
    { column: 'first_name', ascending: true },
    { column: 'last_name', ascending: false },
  ])

Describe alternatives you’ve considered

I tried multiple .order methods and this didn’t appear to work (maybe I screwed up the logic?)

const { data, error } = await supabase
  .from('customer')
  .select('first_name', 'last_name')
  .order('first_name', { ascending: true })
  .order('last_name, { ascending: false });

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
steve-chavezcommented, Feb 28, 2022

I tried multiple .order methods and this didn’t appear to work

Hm, that should work, it’s tested here:

https://github.com/supabase/postgrest-js/blob/5f47e84e917448d792c89e5be29c2f643c2a82ab/test/transforms.ts#L12-L19

Can you double check? Perhaps share some sample data and the supabase-js output.

2reactions
steve-chavezcommented, Aug 10, 2022

@spyl94 Cool! Thanks for confirming.

To close this one I think we’d need an additional example(“ordering multiple columns”) here: https://supabase.com/docs/reference/javascript/order#examples

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Sorting a table using multiple columns
If you want to sort a table by multiple columns, the only option you have is to have a concatenated column with the...
Read more >
How To Sort A Table Using Multiple Columns In Power BI
Press Shift + Left Click on the Header Column on which you wish to apply Multiple Sort. Here, we will select the Order...
Read more >
SQL - Multiple Column Ordering - GeeksforGeeks
Order By: It is used to sort the result-set in ascending or descending order. It sorts the records in ascending order by default....
Read more >
Sort data (Power Query) - Microsoft Support
Sort data based on multiple columns · To open a query, locate one previously loaded from the Power Query Editor, select a cell...
Read more >
Sorting a Power BI table by multiple columns
– There is no limit on the number of columns that can be used to sort a table. Just hold the shift key...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found