Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11287
    LTT
    Participant

    I think the [Stable Sort] Option is not working correctly.

    For example, the original text (Tab-separated):
    z z
    z y
    a b
    a a

    In TSV mode:
    No matter if the [Stable Sort] option is on or off, [Sort A to Z] (by the 1st column) always gives the Stable sort:
    a b
    a a
    z z
    z y

    In normal mode:
    No matter if the [Stable Sort] option is on or off, [Sort A to Z] always gives the Non-Stable sort:
    a a
    a b
    z y
    z z

    #11288
    Yutaka Emura
    Keymaster

    Hello LTT,

    This is a correct behavior.

    In normal mode, “a a” should come earlier than “a b”, so

    a a
    a b
    z y
    z z

    is correct.

    #11290
    LTT
    Participant

    But how to do Non-Stable sort in TSV mode?
    Or, How to use the [Stable Sort] option?

    #11291
    Yutaka Emura
    Keymaster

    Hi LTT,

    You will have to change to Normal mode before you sort, and then change back to TSV mode. Does this answer your question?

    #11292
    LTT
    Participant

    Sorry but I still don’t know when to use the [Stable Sort] option in [Tools >> Customize >> Sort]. :-(

    #11294
    Yutaka Emura
    Keymaster

    Hi LTT,

    If the Stable Sort is on, in TSV mode, and if the cursor is at the first column,

    a b
    a a
    z z
    z y

    is correct. Only the first column is used to sort, and the second column order is unchanged. If the Stable Sort is off, the second column order can be changed (the behavior is undefined).

    Stable Sort is useful if you want to maintain the order of more than one column where there are multiple columns.

    #11302
    LTT
    Participant

    If the Stable Sort is off, the second column order can be changed (the behavior is undefined).

    Could you give an example that in TSV mode the Non-Stable sort result differs from the Stable one?

    #11303
    Yutaka Emura
    Keymaster

    You will need to use a large file to test this.

    Please try this:

    file deleted

    and then you can sort with stable sort, without stable sort, and compare two. I found these differences:

    stable sort:

    10012 10012
    10012 20012
    10013 10013
    10013 20013
    10014 10014
    10014 20014
    10015 10015
    10015 20015

    non-stable sort:

    10012 20012
    10012 10012
    10013 20013
    10013 10013
    10014 20014
    10014 10014
    10015 20015
    10015 10015

    The non-stable sort result may be different from yours since the behavior is undefined.

    Thanks!

    #11305
    LTT
    Participant

    Thank you very much for the explanation and the example.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.