Sort a table
Verified
Added by iNTERFACEWARE
Use table.sort() to sort the items within a table
Source Code
-- sort numbers t = {3,2,1} table.sort(t) trace(t) --> {1,2,3} -- sort characters t = {'c','b','a'} table.sort(t) trace(t) --> {'a','b','c'} -- sort characters t = {'3','2','1','c','b','a'} table.sort(t) trace(t) --> {'1','2','3','a','b','c'} -- error cannot compare numbers and characters when sorting t = {3,2,1,'c','b','a'} table.sort(t)
Description
Use table.sort() to sort the items within a table
Usage Details
Use table.sort()
to sort the items within a table. Items must all be of the same type, the sort fails if you try to sort a mixture of item types.
Note: Sorting sparse tables/arrays does not work. It produces unpredictable results, and occasionally errors.
How to use the snippet:
- Paste the desired sort into your script
More Information
Added by iNTERFACEWARE
Using date and time functions with some formatting examples
Added by iNTERFACEWARE
Use table.insert() to insert an element into a table
Added by iNTERFACEWARE
Use node.insert() to insert a node into an XML node tree
Added by iNTERFACEWARE
Use conn:execute() to insert data into a database table
Added by iNTERFACEWARE
Use conn:merge{} to merge data into a database
Added by iNTERFACEWARE
How to parse an HL7 message and create an HL7 output message
Added by iNTERFACEWARE
How to parse an X12 message using x12.parse()
Added by iNTERFACEWARE
How to parse an XML message using xml.parse()
Added by iNTERFACEWARE
How to parse and serialize JSON, using json.parse{} and json.serialize{}
Added by iNTERFACEWARE
Use iguana.isTest() to allow code to run in the editor but not in the live channel
Added by iNTERFACEWARE
Use iguana.isTest() to prevent code from running in the editor
Added by iNTERFACEWARE
Use conn:query() to select data from a table in a database
Added by iNTERFACEWARE
Use the error() function to raise an error and write it to the logs
Added by iNTERFACEWARE
Use os.fs.glob() to return to process a list of filenames and statistics matching a specified pattern
Added by iNTERFACEWARE
How to open and read a file from disk, either one line at a time, or read the whole file at once
Added by iNTERFACEWARE
How to remove duplicate words from a string, using PCRE regex with string.rxsub()
Added by iNTERFACEWARE
Use os.fs.rename() to rename a file or directory, if the file or directory does not exist an error is returned
Added by iNTERFACEWARE
Use string.gsub() to find and replace one or more instances of text within a string
Added by iNTERFACEWARE
Execute programs and batch files, you can also load results from a directory listing etc.
Added by iNTERFACEWARE
Use iguana.setChannelStatus{} to set the channel dashboard channel status "light" and message