itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 71 forks source link

Sort entries in month view according to begin time #210

Closed rtega closed 1 year ago

rtega commented 1 year ago

In the month view entries are sorted first according to the calendar to which they belong then according to the time. One would expect this to be according to time first and then to calendar.

A typical example would be something like this: vimcalendarissuesort

This should be sorted: 16:00 17:30 18:00

Or did I overlook some option for this?

rtega commented 1 year ago

To answer my own question this could easily be accomplished by adding this line call sort(evts.events, function('calendar#view#month#day_sorter')) before https://github.com/itchyny/calendar.vim/blob/5ab65172102035d93fabb7f9c31b8539618a6297/autoload/calendar/view/month.vim#L235

And adding this function:

function! calendar#view#month#day_sorter(x, y) abort
  return a:x.sec == a:y.sec
        \   ? (get(a:x, 'summary', '') > get(a:y, 'summary', '') ? 1 : -1)
        \ : a:x.sec > a:y.sec ? 1 : -1
endfunction
rionda commented 1 year ago

The same issue also holds for other views, as I'm seeing it in the week view.

rtega commented 1 year ago

Probably the same issue.