We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d32c976 commit 6e54c7cCopy full SHA for 6e54c7c
src/matrix.ts
@@ -83,11 +83,20 @@ export class SparseMatrix {
83
}
84
85
86
- getAll(): { value: number; row: number; col: number }[] {
87
- let rowColValues: Entry[] = [];
+ getAll(ordered = true): { value: number; row: number; col: number }[] {
+ const rowColValues: Entry[] = [];
88
this.entries.forEach((value) => {
89
rowColValues.push(value);
90
});
91
+ if (ordered) { // Ordering the result isn't required for processing but it does make it easier to write tests
92
+ rowColValues.sort((a, b) => {
93
+ if (a.row === b.row) {
94
+ return a.col - b.col;
95
+ } else {
96
+ return a.row - b.row;
97
+ }
98
+ });
99
100
return rowColValues;
101
102
0 commit comments