Skip to content

Sort First Column

bocchino edited this page Oct 6, 2021 · 1 revision

Input

A column vector D

Output

D with the instances and ports in the first column vertically sorted

Procedure

  1. Compute a rank for every port in D. A port p1 has lower rank than p2 if it is above or to the left of p2 in the drawing of D.

  2. Compute an output score for every output port vector V in D.

    1. Associate with each output port in V the rank of the input port to which it is connected.

    2. Let min be the minimum rank and max be the maximum rank.

    3. Return the interval (min, max) as the score.

  3. Compute a score for every instance I in D.

    1. If there are no output ports in I, then return a default score (0, N), where N is a large number. This ensures that I will never compare less than or greater than any other instance.

    2. Otherwise the score is an interval (min, max), where min is the min of the min over all the scores of the output port vectors in I, and max is the max of the max.

  4. Sort the instances according to their scores, lowest first, where (min1, max1) < (min2, max2) if max1 < min2.

  5. For each instance, sort the port vectors according to their scores.

Clone this wiki locally