Example Code

Finding the Original Index of Elements in a Sorted Array

Code and Documents

Attachment

Download All

Overview

This VI takes an Array, sorts it, and then builds it into a 2D array along with the index of each element in the original array.


Description

This VI uses a for loop and the Search 1D Array function. The Search 1D Array function searches in the original array for each element in the sorted array, and returns the index of that element in the original array. The sorted array and the array of original indexes is then built into a 2D array.


Steps to Execute Code

1.     Download SortIndexArray.vi

2.     Open SortIndexArray.vi

3.     Run SortIndexArray.vi

Requirements

Software

LabVIEW 2009 or later


Additional Images

Front Panel:

SortIndexArrayFP.PNG

Block Diagram:

SortIndexArrayBD.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
roopesh689
Member
Member
on

This VI fails when array elements includes more than one zero's.

mpliax
Member
Member
on

That's true; It actually finds the first instance of the number and keeps its index. That means that every duplicate number will have the same index.

Contributors