how to sort organizations alphabetically while retrieving organizations using search API. | Community
Skip to main content

how to sort organizations alphabetically while retrieving organizations using search API.

  • February 7, 2022
  • 1 reply
  • 0 views

i am using following code to retrieve organizations.


client.request('/api/v2/search.json?'+encodeURI('query=type:organization name:'+searchString+'*')).then(updateUI);

 

i want to sort results according to alphabetical order of organizations names. i have tried sort_by parameter but didn't worked.

1 reply

Guided
  • February 7, 2022

Hey suyogAgent,

You probably want to sort it on your end.

Something like:

organizations.sort((a, b) => a.name.localeCompare(b.name));