Entradas

Mostrando entradas de abril, 2022

Case-insensitive string sorting

Imagen
Today I'm gonna talk about a very simple issue: sorting a string array. In LabVIEW , the default behavior is a case-sensitive sorting. That's to say, "Beta" will be sorted above "alfa", just because upper case letters are considered to be before their lower case counterparts. Obviously, sometimes we'll need a case-insensitive sorting , while not losing the original casing (let's say, when sorting a filenames list). So, what's the fastest and simplest way of achieving it? I'm partial to this one: building a cluster array where the first element is the lower case version of our string, and the second one is the original string. When sorting clusters, LV will do it based on the first element, so after that we just need to extract the second element from each cluster in the array, and it's done! Download (VI for LabVIEW 2016) Incidentally, this VI exposes the Sort 1D Array primitive, that has been hidden on the last LabVIEW versio