Skip to content

Goals get automatically ordered by length #60

@bjornasm

Description

@bjornasm

I have a weird issue where my goals are ordered by increasing time:

>Enter goal ('help' to learn): 10m;1m;10m;1m;loop2

followed by i to show info shows:

  > 1. time: feb. 28, 01:29:01 (pending: 00h 00m 58s), goal: 1m                                                                                 
    2. time: feb. 28, 01:29:01 (pending: 00h 00m 58s), goal: 1m                                                                                 
    3. time: feb. 28, 01:38:01 (pending: 00h 09m 58s), goal: 10m                                                                                
    4. time: feb. 28, 01:38:01 (pending: 00h 09m 58s), goal: 10m                                                                                
       sprint 1/2   

so instead of having several 10m long sprints with 1min inbetweet, it seems to knock off the shortest ones first.

However if I follow the example:

25m;30m;55m;1h;1h25m;1h30m;1h55m;2h25m;loop2

It correctly follows the order from the input, as it is increasing in time:

  > 1. time: feb. 28, 01:54:34 (pending: 00h 24m 58s), goal: 25m                                                                                
    2. time: feb. 28, 01:59:34 (pending: 00h 29m 58s), goal: 30m                                                                                
    3. time: feb. 28, 02:24:34 (pending: 00h 54m 58s), goal: 55m                                                                                
    4. time: feb. 28, 02:29:34 (pending: 00h 59m 58s), goal: 1h                                                                                 
    5. time: feb. 28, 02:54:34 (pending: 01h 24m 58s), goal: 1h25m                                                                              
    6. time: feb. 28, 02:59:34 (pending: 01h 29m 58s), goal: 1h30m                                                                              
    7. time: feb. 28, 03:24:34 (pending: 01h 54m 58s), goal: 1h55m                                                                              
    8. time: feb. 28, 03:54:34 (pending: 02h 24m 58s), goal: 2h25m     

However if I add a shorter time at the end, it ends up to be sorted:
25m;30m;55m;1h;1h25m;1h30m;1h55m;2h25m;25m;loop2

Trial and error

The following input ends up to be sorted by time as well:

 10m;1h;10m;1h;loop2 (mix hours and minutes)
 10m;1m;10m;1m (no loops)
 10m;1m;10m;1m;10m;1m;10m; (longer sequence)
 7m;6m;5m;4m;3m;2m;1m (no recurring sequence)

Have I misunderstood anything?

EDIT:
Seems like its this line responsible for the sorting:

goalarraysorted=("${(o)goalarray[@]}")

I suppose this must be intended and supporting some kind of use case that I don't have (I really cant see how anyone would input these in a different order than what they want) - but maybe there should be a flag to load the time sequences exactly as input?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions