TCL function for sorting a file in reverse order

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL function for sorting a file in reverse order

  • Creator
    Topic
  • #53101
    Faraz Khan
    Participant

      This function is using Unix sort command to sort the input file in reverse order.

      It will accept two parameters.

      1. SourceFileName

      2. TargetFileName

      proc fnSortTheFileInReverseOrder { sourceFileName targetFileName args } {

      if { ![ file exists $sourceFileName]} {

      return 1

      }

      if { $targetFileName == “” } {

      set $targetFileName “$sourceFileName.srt”

      }

             if [ catch { exec sort -r $sourceFileName > $targetFileName } err ] {

                 echo ” Error occurred while reverse sorting the $sourceFileName file nError: $err…”

                 return 1

             }

      return 0

      }

      Usage:  

      fnSortTheFileInReverseOrder $sourceFileName  $targetFileName

    • The forum ‘Cloverleaf’ is closed to new topics and replies.