<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Returns Indices that Sort a Vector</title>
<meta name="description" id="description" content="Returns Indices that Sort a Vector"/>
<meta name="keywords" id="keywords" content=" index_sort sort index "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_index_sort_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="ta_free_all.xml" target="_top">Prev</a>
</td><td><a href="index_sort.cpp.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>library</option>
<option>index_sort</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>index_sort</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>index_sort-&gt;</option>
<option>index_sort.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>keys</option>
<option>ind</option>
<option>Example</option>
</select>
</td>
</tr></table><br/>



<center><b><big><big>Returns Indices that Sort a Vector</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<br/>

<code><font color="blue"><span style='white-space: nowrap'>#&#xA0;include&#xA0;&lt;cppad/near_equal.hpp&gt;<br/>
index_sort(</span></font><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>


<br/>
<br/>
<b><big><a name="keys" id="keys">keys</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i></code>
 has prototype 

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorKey</span></font></i><font color="blue"><span style='white-space: nowrap'>&amp;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
where 
<code><i><font color="black"><span style='white-space: nowrap'>VectorKey</span></font></i></code>
 is 
a <a href="simplevector.xml" target="_top"><span style='white-space: nowrap'>SimpleVector</span></a>
 class with elements that support the <code><font color="blue">&lt;</font></code>
operation.

<br/>
<br/>
<b><big><a name="ind" id="ind">ind</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i></code>
 has prototype 

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorSize</span></font></i><font color="blue"><span style='white-space: nowrap'>&amp;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
where 
<code><i><font color="black"><span style='white-space: nowrap'>VectorSize</span></font></i></code>
 is 
a <a href="simplevector.xml" target="_top"><span style='white-space: nowrap'>SimpleVector</span></a>
 class with elements of type <code><font color="blue">size_t</font></code>.
The routine <a href="checksimplevector.xml" target="_top"><span style='white-space: nowrap'>CheckSimpleVector</span></a>
 will generate an error message
if this is not the case.
The size of 
<code><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i></code>
 must be the same as the size of 
<code><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i></code>

and the value of its input elements does not matter.
<code><span style='white-space: nowrap'><br/>
<br/>
</span></code>Upon return, 
<code><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i></code>
 is a permutation of the set of indices
that yields increasing order for 
<code><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i></code>
.
In other words, for all 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;!=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
,

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'>[</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>]&#xA0;!=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'>[</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i><font color="blue"><span style='white-space: nowrap'>]<br/>
</span></font></code>
and for 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;0&#xA0;,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>...</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>size</span></font></i><font color="blue"><span style='white-space: nowrap'>-2</span></font></code>
,

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;(&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i><font color="blue"><span style='white-space: nowrap'>[&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'>[</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>+1]&#xA0;]&#xA0;&lt;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>keys</span></font></i><font color="blue"><span style='white-space: nowrap'>[&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ind</span></font></i><font color="blue"><span style='white-space: nowrap'>[</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>]&#xA0;]&#xA0;)&#xA0;==&#xA0;false<br/>
</span></font></code>
<br/>
<b><big><a name="Example" id="Example">Example</a></big></b>

<br/>
The file <a href="index_sort.cpp.xml" target="_top"><span style='white-space: nowrap'>index_sort.cpp</span></a>
 contains an example
and test of this routine.
It return true if it succeeds and false otherwise.


<hr/>Input File: cppad/index_sort.hpp

</body>
</html>
