Analyze collection of lines and find the shortest one in each cluster

I have a collection of lines. i want to extract the shortest line segment in each “cluster”/direction. I have tried to experiment using the pipe function, but have not managed to find a good solution. It must be possible to use a function like “trim with brep” and use “inside” parameter?
lines in (1.8 KB)

Like this?

lines in (10.3 KB)