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]})
:echo [(229539777187355, 229539777187355), (487766135067138, 491977135306566), (188325333471071, 188931909913550)]->sort({a, b -> a[0] - b[0]})
Igbanam
On Fri, Dec 5, 2025 at 9:00 AM Igbanam Ogbuluijah <xigbanam@gmail.com> 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'sIn Pythonsorted([(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 vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/CAOmRJrdcaKyCSTTKwMoMef1N5q3_dpUvL5wrR_qgFrhpE6z%3Dpg%40mail.gmail.com.
No comments:
Post a Comment