Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2dee7b6b6fbe98f3c09008278a797d07fc07fdaf
Ticket: 1483802fffffffffffffffffffffffffffffffff
lsort inconsistant behavior for negative value of -index
User & Date: dansic on 2006-05-08 13:31:01
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Platform: Windows XP
    
    When a negative value is given to the -index option of
    lsort inconsistant behavior do occur.
    
    The man page for lsort do not discuss behavior for
    negative value of -index.  One would expect either an
    empty string being returned or preferably an error be
    throwned as when the index is out of range.
    
    For some negative value a sorted list is return but it
    seems that the stable property of lsort is lost.
    
    For some other value a list is returned but whitout any
    discernible sorting.
    
    Finally for some others value an error is throwned. 
    The error is the same as for an out of range positive
    value for -index.
    
    Example:
    
    (bin) 94 % set list2 {{5 4 6} {10 12 11} {2 3 1} {5 7 1}}
    {5 4 6} {10 12 11} {2 3 1} {5 7 1}
    (bin) 95 % lsort -dictionary -index 2 $list2
    {2 3 1} {5 7 1} {5 4 6} {10 12 11}
    (bin) 96 % lsort -dictionary -index -2 $list2
    {2 3 1} {5 7 1} {5 4 6} {10 12 11}
    (bin) 97 % lsort -dictionary -index -3 $list2
    {2 3 1} {5 4 6} {5 7 1} {10 12 11}
    (bin) 98 % lsort -dictionary -index 3 $list2
    element 3 missing from sublist "5 4 6"
    (bin) 99 % lsort -dictionary -index -4 $list2
    {2 3 1} {5 4 6} {5 7 1} {10 12 11}
    (bin) 100 % lsort -dictionary -index -5 $list2
    element -5 missing from sublist "5 4 6"
    (bin) 101 % lsort -dictionary -index -1 $list2
    {2 3 1} {5 4 6} {5 7 1} {10 12 11}
    
    
    (bin) 104 % set list3 {{5 2 3 4 3} {3 6 9 2 7} {5 1 12
    13 15} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5}}
    {5 2 3 4 3} {3 6 9 2 7} {5 1 12 13 15} {9 3 34 12 3} {1
    3 32 24 5} {4 9 3 6 5}
    (bin) 105 % lsort -dictionary -index 0 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1
    12 13 15} {9 3 34 12 3}
    (bin) 106 % lsort -dictionary -index 1 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {3 6 9 2 7} {4 9 3 6 5}
    (bin) 107 % lsort -dictionary -index -1 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 1 12 13 15} {5
    2 3 4 3} {9 3 34 12 3}
    (bin) 108 % lsort -dictionary -index 2 $list3
    {5 2 3 4 3} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} {1 3
    32 24 5} {9 3 34 12 3}
    (bin) 109 % lsort -dictionary -index -2 $list3
    {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3
    6 9 2 7} {5 1 12 13 15}
    (bin) 110 % lsort -dictionary -index 3 $list3
    {3 6 9 2 7} {5 2 3 4 3} {4 9 3 6 5} {9 3 34 12 3} {5 1
    12 13 15} {1 3 32 24 5}
    (bin) 111 % lsort -dictionary -index -3 $list3
    {3 6 9 2 7} {5 2 3 4 3} {4 9 3 6 5} {9 3 34 12 3} {5 1
    12 13 15} {1 3 32 24 5}
    (bin) 112 % lsort -dictionary -index 4 $list3
    {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3
    6 9 2 7} {5 1 12 13 15}
    (bin) 113 % lsort -dictionary -index -4 $list3
    {5 2 3 4 3} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} {1 3
    32 24 5} {9 3 34 12 3}
    (bin) 114 % lsort -dictionary -index 5 $list3
    element 5 missing from sublist "5 2 3 4 3"
    (bin) 115 % lsort -dictionary -index -5 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {3 6 9 2 7} {4 9 3 6 5}
    (bin) 116 % lsort -dictionary -index 6 $list3
    element 6 missing from sublist "5 2 3 4 3"
    (bin) 117 % lsort -dictionary -index -6 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1
    12 13 15} {9 3 34 12 3}
    (bin) 118 % lsort -dictionary -index 7 $list3
    element 7 missing from sublist "5 2 3 4 3"
    (bin) 119 % lsort -dictionary -index -7 $list3
    element -7 missing from sublist "5 2 3 4 3"
    
    (bin) 120 % lsort -index 0 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1
    12 13 15} {9 3 34 12 3}
    (bin) 121 % lsort -index 1 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {3 6 9 2 7} {4 9 3 6 5}
    (bin) 122 % lsort -index -1 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 1 12 13 15} {5
    2 3 4 3} {9 3 34 12 3}
    (bin) 123 % lsort -index 2 $list3
    {5 1 12 13 15} {5 2 3 4 3} {4 9 3 6 5} {1 3 32 24 5} {9
    3 34 12 3} {3 6 9 2 7}
    (bin) 124 % lsort -index -2 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {4 9 3 6 5} {3 6 9 2 7}
    (bin) 125 % lsort -index 3 $list3
    {9 3 34 12 3} {5 1 12 13 15} {3 6 9 2 7} {1 3 32 24 5}
    {5 2 3 4 3} {4 9 3 6 5}
    (bin) 126 % lsort -index -3 $list3
    {9 3 34 12 3} {5 1 12 13 15} {3 6 9 2 7} {1 3 32 24 5}
    {5 2 3 4 3} {4 9 3 6 5}
    (bin) 127 % lsort -index 4 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {4 9 3 6 5} {3 6 9 2 7}
    (bin) 128 % lsort -index -4 $list3
    {5 1 12 13 15} {5 2 3 4 3} {4 9 3 6 5} {1 3 32 24 5} {9
    3 34 12 3} {3 6 9 2 7}
    (bin) 129 % lsort -index 5 $list3
    element 5 missing from sublist "5 2 3 4 3"
    (bin) 130 % lsort -index -5 $list3
    {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5}
    {3 6 9 2 7} {4 9 3 6 5}
    (bin) 131 % lsort -index 6 $list3
    element 6 missing from sublist "5 2 3 4 3"
    (bin) 132 % lsort -index -6 $list3
    {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1
    12 13 15} {9 3 34 12 3}
    (bin) 133 % lsort -index 7 $list3
    element 7 missing from sublist "5 2 3 4 3"
    (bin) 134 % lsort -index -7 $list3
    element -7 missing from sublist "5 2 3 4 3"
    
  4. foundin changed to: "obsolete: 8.4.11"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dansic"
  9. subsystem changed to: "17. Commands I-L"
  10. title changed to:
    lsort inconsistant behavior for negative value of  -index
    
  11. type changed to: "Bug"