To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This is an example of a selection sort.
Description
This VI implements selection sort fully programmed in LabVIEW. In addition, it allows you to set a wait in the main loop and displays the partially sorted array so that you can see the actual process that selection sort takes to sort the array. See the Wikipedia entry for the detailed process on how the sorting is accomplished.
Requirements
Steps to Implement or Execute Code
Additional Information or References
Caveats and Additional Notes
Selection sort has O(n²) complexity meaning in layman's terms that the larger the size of the array, the time it takes to sort and the number of comparisons it makes increases exponentially. There are many sorting algorithms that are much more efficient and take less memory. This algorithm should only be used to learn the process of different sorting methods or in the rare case that you need to actually sort using selection sort. Otherwise, LabVIEW includes a VI called Sort 1D Array.VI that implements a version of Quicksort that should be used instead.
Additional Sorting Examples Programmed in LabVIEW
Block Diagram of Selection Sort VI
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.