LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting Clothing Items in Ascending Order

Solved!
Go to solution

Hi everyone,

I’m working on a project where I need to sort an array of clothing items in ascending order based on a specific sequence. I have three types of clothing items: shoes, pants, and shirt. I want to arrange them in the following order: shoes, pants, and then shirt.

For example:

- Given the 1D string array: pants, shoes, shirt
The output should be: shoes, pants, shirt

- Given the array: pants, pants, shirt, shoes
The output should be: shoes, pants, pants, shirt

- Given the array: shoes, pants, pants, shirt, shoes
The output should be: shoes, shoes, pants, pants, shirt

I’m looking for a way to sort the array such that the items are ordered according to the specified sequence.

thank you!

0 Kudos
Message 1 of 9
(511 Views)

Seems simple enough. What have you tried?

0 Kudos
Message 2 of 9
(494 Views)
Solution
Accepted by topic author maxnoder1995

This is how I would do it.

SortByName.png

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 3 of 9
(493 Views)
Solution
Accepted by topic author maxnoder1995

@ZYOng wrote:

This is how I would do it.


and this is how I would do it. 😄

 

altenbach_0-1723927169279.png

 

Of course if there could be unlisted items in the array or if we need to ignore upper/lower case, etc. a little bit more code is needed once we know the extra behavior needed.

 

Comments for the earlier solution posted:

Three stacked structure, two shift registers, two different output tunnels (conditional indexing on a while loop and a concatenating tunnel on a FOR loop), delete from array in a tight loop (big no-no!) all seems a bit convoluted for such a simple problem. 😄

 

 

Message 4 of 9
(485 Views)

I did it in key-value form and in a much more complicated way. It definitely makes a lot more sense when I see the solution

0 Kudos
Message 5 of 9
(483 Views)

Thanks! its great

0 Kudos
Message 6 of 9
(477 Views)

Or alternatively:

 

raphschru_1-1723940102819.png

 

which you can easily extend in case you want to sort by multiple criteria.

 

Regards,

Raphaël.

Message 7 of 9
(430 Views)

Just for fun. (i know it can be improved with Maps, but i'm still unused to those)

Yamaeda_0-1724158544324.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(325 Views)

Here's a simple "Count and Concatenate" solution that doesn't actually sort anything.

NIquist_0-1724165483749.png

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 9 of 9
(309 Views)