// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.sort('key', function (err, values) {
  // callback called once the action has completed

// Using promises (NodeJS only)
  .then(values => {
    // resolved once the action has completed
kuzzle.memoryStorage.sort("key", new ResponseListener<String[]>() {
  public void onSuccess(String[] values) {
    // callback called once the action has completed

  public void onError(JSONObject error) {

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');

try {
  $values = $kuzzle->memoryStorage()->sort('key');
catch (ErrorException $e) {


Callback response:

  "sorted element1",
  "sorted element2",

Sorts and returns elements contained in a list, a set of unique values or a sorted set. By default, sorting is numeric and elements are compared by their value interpreted as double precision floating point number.

[Redis documentation]

sort(key, [options], callback)

keystringKey identifier
optionsJSON ObjectOptional parameters


alphabooleanPerform an alphanumerical sort instead of a numeric onefalse
bystringInstead of sorting the values stored at key, use them to complete the provided key pattern, and return the sorted list of values stored in those keys.null
directionstringSort in ascendant (ASC) or descendant (DESC) orderASC
getarraySort the values stored at key but, instead of returning these directly, return the values contained in external keys, using the provided array of patterns completed by the sorted valuesnull
limitarrayLimit the result set to a range of matching elements (similar to SELECT LIMIT offset, count in SQL).
Format: [<offset(int)>, <count(int)>]
queuablebooleanMark this request as (not) queuabletrue

Callback response

Resolves to an array of sorted values.