I had a need to sort a string array and I found some code on Real Gagnon’s website that sorted numbers by creating a DataStore/DataWindow on the fly and used that to sort. Someone added a comment that for strings you need to define the column as char to avoid errors. I improved the code by adding a loop to determine the longest string in the array and using that when defining the DataWindow source.
public function boolean of_sortarray (ref string as_array[], string as_order);// —————————————————————————–
// SCRIPT: of_SortArray
//
// PURPOSE: This function sorts the passed array using a DataStore created
// on-the-fly.
//
// This is based on code from Real Gagnon:
// http://www.rgagnon.com/pbdetails/pb-0114.html
//
// ARGUMENTS: as_array – Array of values to sort
// as_order – The sort order:
//
// Order value Resulting sort order
// ———————— —————————
// a, asc, ascending, ai, i Case-insensitive ascending
// d, desc, descending, di Case-insensitive descending
// as, s Case-sensitive ascending
// ds Case-sensitive descending
//
// DATE PROG/ID DESCRIPTION OF CHANGE / REASON
// ———- ——– —————————————————–
// 09/27/2016 RolandS Initial Coding
// —————————————————————————–