GNU bug report logs -
#50878
[PATCH] union: Resolve collisions by stable-sort'ing them.
Previous Next
Full log
Message #23 received at 50878 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Attila Lendvai schreef op do 30-09-2021 om 08:10 [+0000]:
> > > - (let* ((original-files (list->vector files))
> > > - (count (vector-length original-files))
> > > - (stripped-files (vector-map (lambda (_ el)
> > > - (strip-store-file-name el))
> > > - original-files))
> > > - (indices (vector-unfold values count)))
> > >
> > > - (stable-sort! indices
> > > - (lambda (a b)
> > > - (string> (vector-ref stripped-files a)
> > > - (vector-ref stripped-files b))))
> > > - (vector-ref original-files (vector-ref indices 0))))
> >
> > Instead of stable-sort!-ing the indices of a vector, what about stable-
> > sort!-ing (map strip-store-file-name original-files) in more or less
> > one go?
>
> the hash also needs to be dropped from the path for sorting to be
> useful, but the return value must be the full path, hence the
> complexity with sorting the indices, pointing both to the full paths
> and the cut parts.
You can replace the 'less' argument of 'stable-sort'.
Example sorting by the second character of a string:
(sort '("za" "yb" "xc") (lambda (x y)
(char>? (string-ref x 1)
(string-ref y 1)))))
IIUC, you would need to replace char>? by string> and string-ref
by strip-store-file-name.
Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 2 years and 284 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.