TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohd Kashif
750
941
224.4k
Write sorting for date and name in javascript?
May 2 2019 1:29 AM
How to write sorting for date and name in js?
i have one table. there are 2 column like name and created date
name: ["A", "A9", "A10", "A11", "A3"]
createdDate: ["Apr 2, 2019 3:07 PM", "Apr 10, 2019 9:25 AM", "Apr 30, 2019 6:08 PM", "Apr 10, 2019 8:25 AM", "Apr 2, 2019 8:07 PM"]
and output should like this :
name: ["A", "A3", "A9", "A10", "A11"]
createdDate: ["Apr 2, 2019 3:07 PM", "Apr 2, 2019 8:07 PM","Apr 10, 2019 8:25 AM", "Apr 10, 2019 9:25 AM", "Apr 30, 2019 6:08 PM"]
I already try using sort method.
.sort(a,b){
var firstEl = (a === undefined) ? a :a.toUpperCase();
var secondEl = (b === undefined) ? b: b.toUpperCase();
if(firstEl === undefined || firstEl === "") {return (1)}
if(secondEl === undefined || secondEl === "") {return (-1)}
if(firstEl === secondEl) {return 0;}
return firstEl < secondEl ? (-1) : (1 );
}
but its not workign for alhanumeric value
Reply
Answers (
2
)
Is there any hosting which give us full access
My zip file is not extract on plesk.