-1

Is there any option to pass custom sorting order in url? For example, I have some statuses (OPEN, CLOSED, PENDING) and I want to order it like PENDING, CLOSED, OPEN. Can I pass this order in url (I don't want to use ascending, descending)? Something like:

/tasks?sort=status,[PENDING,CLOSED,OPEN]
Helosze
  • 333
  • 2
  • 7
  • 20
  • 2
    `/tasks?sort=PENDING&sort=CLOSED&sort=OPEN` – RobOhRob Jul 03 '19 at 14:32
  • 1
    This can be received in spring as a `List` giving you the sort order – RobOhRob Jul 03 '19 at 14:32
  • Some related literature [here](https://stackoverflow.com/questions/24059773/correct-way-to-pass-multiple-values-for-same-parameter-name-in-get-request). – Mena Jul 04 '19 at 07:13
  • Your question is a bit vague. What this endpoint. A Spring MVC Controller? A Spring Data Rest controller? What is the datastore? – Alan Hay Jul 04 '19 at 07:59

1 Answers1

1

There is no custom ordering feature as you need. You have to design with your own efforts.

You need to implement a business which includes these steps:

  • Pass your argument which includes the order of the field to a server by querystring or JSON (more preferable IMO).
  • After that, you can take that array which includes the order of your objects.
  • As a last, order/recreate your list based on a field which listed inside that array.
mdoflaz
  • 551
  • 6
  • 19