.localeCompare Number func
return [...this.posts].sort((post1, post2) => String(post1[this.selectedSort])?.localeCompare(String(post2[this.selectedSort])));
Joyous Jay
return [...this.posts].sort((post1, post2) => String(post1[this.selectedSort])?.localeCompare(String(post2[this.selectedSort])));