diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2024-05-08 05:33:34 -0400 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2024-05-08 05:33:34 -0400 |
| commit | 2c6f685b705ceefd682bea8e8c9f3f6e94a6e918 (patch) | |
| tree | 80c9f2ae795bb2ff205d9199f2df905e21b305ad | |
| parent | 5b4e5781440ae32756fc7dd30e6bf4f0847c3a01 (diff) | |
Added sortByDate function to handle map entries in blog.js
| -rw-r--r-- | source/blog.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blog.js b/source/blog.js index 8e0922f..a45267e 100644 --- a/source/blog.js +++ b/source/blog.js @@ -57,10 +57,21 @@ class Blog { }) } }) - res(this.blog) + res(this.#OrderByDate(this.blog)) }) }) } + + #OrderByDate(x) { + const entries =[] + x.forEach((value, key) => {entries.push([key, value])}) + entries.sort((a, b) => { + const dateA = b[1].date + const dateB = a[1].date + return dateA - dateB + }) + return new Map(entries) + } } module.exports = () => {return new Blog()} |
