Example Code

Sort String Array Using Common Alphabetical and Numeric Logic

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to sort an Array of strings that contains both numbers and letters.

 
Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Modify input array or use "Logical String Array Sort LV_2012_NI_Verified" as subVi
  2. Run the program 

 

Additional Information or References

VI Block Diagram

 Logical String Array Sort LV_2012_NI_Verified.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support

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

Comments
KrisnaWisnu
Member
Member
on

just what i am looking for.

Certified LabVIEW Developer (CLD)
Certified TestStand Developer (CTD)
Using LabVIEW 8.5.1 (2008) to LabVIEW 2024
Aventador
Member
Member
on

Thanks a ton mate ! Helped me big time in a crucial situation !

-------------------------------------------------------------------------------
Subramanian
LabVIEW Developer


Life may control my car, but I steer it ! !
Penoff
Member
Member
on

Good but far from perfect. There are cases when the result just doesn't make sense. Also it doesn't care for negative numbers. All short strings come after the long ones. I am looking for quite some time for a good logical sorting algorythm, but I still can't find one that fulfills my needs.

JHaas
Member
Member
on

Beautiful....did just what I needed. Saved lots of time. Thanks!

Jim Haas
ashesman1
Member
Member
on

Awesome, thanks.  That got the job done from start of searching to implmented in two minutes!

nrosenberg340
Member
Member
on

Thanks for putting this together, works most of the time.  However, I find that it sorts everything with a 9x in it incorrectly.  

 

I have a folder with 10k files, this sorts the files between 90-99 and shuffles in 901, 902, 903, etc.  Ie, the list I get out the other side is 90, 91, 901, 92, 902, etc.  Any ideas here?

 

Nate