"sort" (vector::sort / dyn_*::sort)

Sorts the array.

Synopsis

int vector.sort(bool ascending = true);

int vector.sort(string memberName, bool ascending = true);

int vector.sort(function_ptr memberFunc, bool ascending = true);

Parameters

Parameter Description
ascending Sorting order
memberName Class member used for sorting
memberFunc Class member function used for sorting

Description

Sorts the array ascending or descending (ascending = false).

If the array contains class objects or shared_ptr to class objects, memberName defines which class member is used for the comparison of the objects. The member can also be private or protected. Here memberName is used in a similar way as in indexListOf().

A class member function can also be given. Here memberFunc is used in a similar way as in indexListOf().

The function must be implemented like this:

class MyClass
{
  public int compare(const  MyClass &other) { ... }
};

An int value must be returned:

  • 0 if this and the given other object are the same
  • -1 if the this object is less than the other
  • 1 if this object is greater than the other

Assignment

Vector / dyn_*