Hi,

On Fri, Dec 5, 2025 at 1:11 AM Igbanam Ogbuluijah <[email protected]>
wrote:

> I am realizing you can reduce the problem to just the first three entries,
> so you don't have to copy much when reproducing
>
> :echo [(229539777187355, 229539777187355), (487766135067138,
> 491977135306566), (188325333471071, 188931909913550)]->sort({a, b -> a[0] -
> b[0]})
>
>
This is a bug in the code.  I will create a PR this weekend.

- Yegappan


>
> *Igbanam*
>
>
> On Fri, Dec 5, 2025 at 9:00 AM Igbanam Ogbuluijah <[email protected]>
> wrote:
>
>> Hi all,
>>
>> It's the time of the year when I use Vimscript to do what it was not
>> designed for: AdventOfCode.
>>
>> For today's problem, I notice that `:h sort()`, with a Funcref, breaks
>> for large numbers — "breaks" here means that it does not keep to contract
>> in the docs, not that it throws an exception. Since it's not really an
>> exception, I don't think I can file it as a bug… so I'm bringing it here.
>> Maybe someone can help me catch what I'm doing wrong.
>>
>> In Vimscript…
>>
>> :echo [(229539777187355, 229539777187355), (487766135067138,
>> 491977135306566), (188325333471071, 188931909913550), (264028451845520,
>> 265514296554744), (245727634348687, 249469249579525), (375117820166731,
>> 378942174241518), (535474757750378, 535849288071548)]->sort({a, b -> a[0] -
>> b[0]})
>>
>> yields
>>
>> [(229539777187355, 229539777187355), (487766135067138, 491977135306566),
>> (188325333471071, 188931909913550), (264028451845520, 265514296554744),
>> (245727634348687, 249469249579525), (375117820166731, 378942174241518),
>> (535474757750378, 535849288071548)]
>>
>> This is the same list because I got it from runtime working on the larger
>> list.
>>
>> Looking closely, I noticed that the third range is smaller than the first
>> range. This got me thinking about things like overflow. But I checked and 
>> `v:numbermax
>> == 9223372036854775807` which is bigger than all the numbers here.
>>
>> This same operation in Python and Ruby yield the same results different
>> from Vimscript's
>>
>> In Python
>>
>> sorted([(229539777187355, 229539777187355), (487766135067138,
>> 491977135306566), (188325333471071, 188931909913550), (264028451845520,
>> 265514296554744), (245727634348687, 249469249579525), (375117820166731,
>> 378942174241518), (535474757750378, 535849288071548)])
>>
>> In Ruby
>>
>> [[229539777187355, 229539777187355], [487766135067138, 491977135306566],
>> [188325333471071, 188931909913550], [264028451845520, 265514296554744],
>> [245727634348687, 249469249579525], [375117820166731, 378942174241518],
>> [535474757750378, 535849288071548]].sort { |a, b| a[0] - b[0] }
>>
>> …both yield
>>
>> [(188325333471071, 188931909913550), (229539777187355, 229539777187355),
>> (245727634348687, 249469249579525), (264028451845520, 265514296554744),
>> (375117820166731, 378942174241518), (487766135067138, 491977135306566),
>> (535474757750378, 535849288071548)]
>>
>> Is there some way to use sort that I'm missing here?
>>
>>
>> *Igbanam*
>>
>
>

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_use/CAAW7x7ki7k4djawX6-4DkJjx7Vy2dFyy9QbD9Q8doNwNvJ3Ffg%40mail.gmail.com.

Reply via email to