Comment

Comment by shepmaster

I often want to sort within a line:

    [“zoo”, “cow”]
Would become

    [“cow”, “zoo”]
Any tips on how to do that? Ideally using just built in functions…

I usually insert newlines between the elements, use a line-based sort, then recombine the lines. That works but is more tedious than I’d like. I’ve never taken the time to wrap that logic it in a function because it’s infrequent and it seems like it’s always slightly different.

parent shepmaster 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton