URL query string convention for multiple sort

后端 未结 3 476
醉酒成梦
醉酒成梦 2021-02-01 06:59

I have a RESTful web application that supports multiple sort fields on a collection of items. Is there a common convention for encoding these sort fields into the query string o

3条回答
  •  清酒与你
    2021-02-01 07:41

    I've done this before using the standard SQL sorting syntax. There are numerous parsing functions and techniques out there.

    http://myapp.com/books?sort=author asc,datepublished desc&count=12
    

    which would be encoded to

    http://myapp.com/books?sort=author+asc,datepublished+desc&count=12
    

提交回复
热议问题