Problem

Complete the given apex REST API method to return the list of accounts from salesforce. Ensure that the response contains the accounts sorted in ascending order by account name.


Instructions:


1. Query the list of accounts.


2. Sort the accounts in ascending order by name.


3. Return the sorted records in the REST API response.



Example:


curl https://your-salesforce-org-domain/services/apexrest/get-accounts

// API Response

[
 {
 "Name": "Burlington Textiles Corp of America",
 "Id": "0015h00001YmO9jAAF",
 "url": "/services/data/v56.0/sobjects/Account/0015h00001YmO9jAAF",
 "type": "Account"
 }
]


Note : This apex practice example aims to introduce you to writing a simple Apex REST API GET method. The method returns a set of records from the Salesforce Account object.