If you have this in a single string then do.
// first create an array by splitting the string at the newlines
var list = dateString.split('\n');
list = list
.map( // for each element in the list (each date)
function(val,idx){
// use the first part(before the dot(.)), replace the - with spaces and convert to date
return new Date(val.split('.')[0].replace(/-/g,' '));
})
.sort(); // at the end sort the results.
example at http://www.jsfiddle.net/gaby/rfGv8/
What we need to do for each date (line) is
2010-11-08 18:58:50.0_getCreated_10180 (remove the part after the .)
accomplished with val.split('.')[0]
then replace the - with a space to make it look like 2010 11 08 18:58:50
which is an acceptable date format for the Date
constructor.
accomplished with val.split('.')[0].replace(/-/g,' ')
Then pass it as a parameter to the constructor of Date to create a Date object
accomplished with new Date(val.split('.')[0].replace(/-/g,' '))
after applying the above to all elements and getting a new array use the .sort()
method to sort the array in Ascending order.