Get elements in order by wire connection?

Hey is it possible too get elements in the order by the wire connection? any ideas on how?

thinking about a script that can change running index on the elements by order on the wire.