# SortEdges

Sorts arrays of edges by the specified criteria.

## SortEdges Inputs

Parameter | Description
Edges | A reference to a spreadsheet cell containing an Edge data structure. The Edges data structure must consist of multiple straight-line edges.
Number to Sort | Specifies the number of edges to sort (0 to 2591; default = 2).
Sort By | Specifies the method by which the edges are sorted.
0 = best score | Sort by order of descending contrast scores.
1 = first-to-last (default) | Sort by the original scan direction.
2 = B2W by score, W2B by score | Sort first by polarity, then by score.
3 = B2W first-to-last, W2B first-to-last | Sort first by polarity, then by original scan order.
4 = last-to-first | Sort by reverse scan order.
Show | Specifies the display mode for SortEdges graphical overlays on top of the image.
0 = hide all (default) | All graphics will be hidden, except when the cell containing the SortEdges function is the active cell in the spreadsheet.
1 = result graphics only | The line edges will be displayed at all times.

## SortEdges Outputs

Returns | An Edge data structure containing sorted edges, or #ERR if any of the input parameters are invalid.
Results | When SortEdges is initially inserted into a cell, a result table is created in the spreadsheet. The following Edges Vision Data Access functions are automatically inserted into the spreadsheet to create the result table:
Label | Function | Description
Index |  | Index position
X0 | GetX(Edges, Edge Index, 0) | The x-coordinate of the first endpoint.
Y0 | GetY(Edges, Edge Index, 0) | The y-coordinate of the first endpoint.
X1 | GetX(Edges, Edge Index, 1) | The x-coordinate of the second endpoint.
Y1 | GetY(Edges, Edge Index, 1) | The column coordinate of the second endpoint.
Score | GetScore(Edges, Edge Index) | The edge contrast score.