Answered by:
Date Sorting of ISet collection
Question

User2096382003 posted
I am looking how to do sorting on a collection of dates.
These are coming in as an ISet<DateTime> collection. ie (20050701, 20050102, 20050101, 20050503)
I need to determine from this collection which dates contain an 'R' and sort these in ascending order... the others will sort in descending order
so the above would result in 20050101, 20050102, 20050701, 20050503
whats the best approach to solve this?
Tuesday, May 12, 2020 8:30 PM
Answers

User288213138 posted
Hi mark1961,
so the above would result in 20050101, 20050102, 20050701, 20050503so essentially these will be ascending order of date, and other months descendingAccording to your description, I cannot understand your requirement.
If you want to sort in ascending order by date, then the result should be 20050101, 20050102, 20050503, 20050701.
If you want to descend by month, then the result should be 20050701, 20050503, 20050102, 20050101.
This can't satisfy these two conditions at the same time.
If I misunderstand your requirement, please post more details information about your requirement.
Best regards,
Sam
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 13, 2020 7:43 AM
All replies

User303363814 posted
A DateTime cannot contain an 'R'? A DateTime is, at its heart, a number. The number of 100nS ticks since some base. There is no 'R' in a DateTime.
Wednesday, May 13, 2020 1:44 AM 
User2096382003 posted
apologies, i meant where the month will contain "R" (date.tostring("MMMM")
so essentially these will be ascending order of date, and other months descending
then latter appended to the former
Wednesday, May 13, 2020 6:17 AM 
User288213138 posted
Hi mark1961,
so the above would result in 20050101, 20050102, 20050701, 20050503so essentially these will be ascending order of date, and other months descendingAccording to your description, I cannot understand your requirement.
If you want to sort in ascending order by date, then the result should be 20050101, 20050102, 20050503, 20050701.
If you want to descend by month, then the result should be 20050701, 20050503, 20050102, 20050101.
This can't satisfy these two conditions at the same time.
If I misunderstand your requirement, please post more details information about your requirement.
Best regards,
Sam
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 13, 2020 7:43 AM