<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css">
<title>
Gambas Documentation - Object[].Sort
 (gb)</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../../../help+en"><img class="flag" alt="Home" border="0" src="../../../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../object[]+en">Up</a>&nbsp;
<a href="push+en">Previous</a>&nbsp;
<a href="_get+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Object[].Sort
 (gb)</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><font color="blue">FUNCTION</font> <b>Sort</b> <font color="blue">(</font> <b>[</b> <u>Mode</u> <font color="blue">AS</font> <font color="#0080FF">Integer</font> <b>]</b> <font color="blue">)</font> <font color="blue">AS</font> <font color="#0080FF"><a href="../object[]+en">Object[]</a></font></pre>
Sorts the array.
<p>
Objects are compared by calling the special <tt>_sort</tt> method.
<p>
This method is called on one <a href="../../../def/object+en">object</a>, and takes one argument, the reference of the other <a href="../../../def/object+en">object</a> it must be compared with.
<p>
It must return the result of the comparison as an integer number:
<ul>
<li><tt>0</tt> if the objects are equal.
<li><tt>1</tt> if the <a href="../../../def/object+en">object</a> is greater than the one passed as argument.
<li><tt>-1</tt> if the <a href="../../../def/object+en">object</a> is lower than the one passed as argument.
<p>
</ul>

If the objects don't implement the special <tt>_sort</tt> method, then they are compared by using their address in memory.

</div>
</body>
</html>

