0.1.0 • Published 7 years ago

vertical-flow-columns v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

vertical-flow-columns

Sorts data for displaying vertical columns when the browser floats them horizontally.

Usage

1 Column (width 100%)

const vfc = require('vertical-flow-columns');
const data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

0
1
2
3
4
5
6
7
8
9

2 Columns (width: 50%)

var sorted = vfc(data, 2);
=> [ 0, 5, 1, 6, 2, 7, 3, 8, 4, 9 ]

0 5
1 6
2 7
3 8
4 9

3 Columns (width: 33.3%)

var sorted = vfc(data, 3);
=> [ 0, 4, 7, 1, 5, 8, 2, 6, 9, 3 ]

0 4 7
1 5 8
2 6 9
3

4 Columns (width: 25%)

var sorted = vfc(data, 4);
=> [ 0, 3, 6, 8, 1, 4, 7, 9, 2, 5 ]

0 3 6 8
1 4 7 9
2 5

Docs

sort(data, n) ⇒ Array

Sorts data for displaying vertical columns when the browser floats them horizontally.

ParamTypeDefaultDescription
dataArrayThe data to be sorted as columns.
nInteger2The number of columns.