• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
        • ValueSet Statement
        • ValueSet.add Function
        • ValueSet.remove Function
        • ValueSet.clear Function
        • ValueSet.length Function
        • ValueSet.randomize Function
        • ValueSet.show Function
        • ValueSet.sort Function
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

ValueSet.sort Function

Format
b = valueset_name.sort(ʃ ascending ‖ descending ʅ ʃ by code ‖ label ʅ);
Description
The ValueSet.sort function sorts the order of entries in the ValueSet object by either label or code. An optional argument, ascending or descending, allows for the specification of the sort order. Another optional argument, by code or by label allows you to specify whether to sort the value set's entries by code or label. By default the value set will be sorted in ascending order by label.
Labels are sorted in case insensitive order, so "c" is considered the same as "C". On the other hand, codes for alphanumeric value sets are sorted in case sensitive order, so "c" is recognized as different from "C".
Return Value
The function returns a logical value of 1 (true).
Example
ValueSet enumerators_vs;

forcase STAFF_DICT where STAFF_ROLE = 1 do
    enumerators_vs.
add(STAFF_NAME, STAFF_CODE);
endfor;

enumerators_vs.
sort();

setvalueset(ENUMERATOR_LOGIN, enumerators_vs);
See also: ValueSet Object, ValueSet.randomize Function