How to sort these lines?
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello!
I really need a help on solving one problem.
I have many lines and I need the way to sort them by specified order. The lines are on picture.
I need them to be sorted in this order:
0 5 1 -- 0 is horizontal start and 5 is horizotal end, 1 is vertical position called height.
0 4 2 -- again 0 is horizontal start, 4 is horizontal end and 2 is vertical position(height)
1 4 3
2 3 4
0 5.5 5
6 7 5
6.0 6.2 2
6.2 6.4 3
6.4 6.6 4
6.6 6.8 3
6.8 7.0 2
9.5 15.5 3
10 12.5 2
12.5 15 2
10 15 1
16 17 5
16.0 16.1 2
16.2 16.3 3
16.4 16.5 4
16.6 16.7 3
16.8 16.9 2
0 18 6
Each line of 3 numbers represent one line on picture. The first number is horizontal start of line and second is horizontal end and third number is vertical position
I really need a help on solving one problem.
I have many lines and I need the way to sort them by specified order. The lines are on picture.
I need them to be sorted in this order:
0 5 1 -- 0 is horizontal start and 5 is horizotal end, 1 is vertical position called height.
0 4 2 -- again 0 is horizontal start, 4 is horizontal end and 2 is vertical position(height)
1 4 3
2 3 4
0 5.5 5
6 7 5
6.0 6.2 2
6.2 6.4 3
6.4 6.6 4
6.6 6.8 3
6.8 7.0 2
9.5 15.5 3
10 12.5 2
12.5 15 2
10 15 1
16 17 5
16.0 16.1 2
16.2 16.3 3
16.4 16.5 4
16.6 16.7 3
16.8 16.9 2
0 18 6
Each line of 3 numbers represent one line on picture. The first number is horizontal start of line and second is horizontal end and third number is vertical position
To earn money on java go to upwork.com
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What are the sorting rules you wish to apply?
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Collection should be sorted from topmost line to bottommost as provided in my topic .
The top line(0,5,1) is the first in sorted collection, the second line(0,4,2) is second in sorted collection. The third line - 1 4 3 is the third in sorted coll.
These three numbers represent coordinates of line on picture:
0 is horizontal start of line
4 is horizontal end of line
1 is vertical position of line.
The top line(0,5,1) is the first in sorted collection, the second line(0,4,2) is second in sorted collection. The third line - 1 4 3 is the third in sorted coll.
These three numbers represent coordinates of line on picture:
0 is horizontal start of line
4 is horizontal end of line
1 is vertical position of line.
To earn money on java go to upwork.com
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
To build the logic, you need to take a step back, forget all the existing data (lines) and formulate the sorting rules in simple english.
e.g.
If the x co-ordinate is the same for given two lines, the line with the higher y coordinate takes precedence over the other line
e.g.
If the x co-ordinate is the same for given two lines, the line with the higher y coordinate takes precedence over the other line
| When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








