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 (2005-07-01, 2005-01-02, 2005-01-01, 2005-05-03)
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 2005-01-01, 2005-01-02, 2005-07-01, 2005-05-03
whats the best approach to solve this?
Tuesday, May 12, 2020 8:30 PM
Answers
-
User288213138 posted
Hi mark-1961,
so the above would result in 2005-01-01, 2005-01-02, 2005-07-01, 2005-05-03so 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 2005-01-01, 2005-01-02, 2005-05-03, 2005-07-01.
If you want to descend by month, then the result should be 2005-07-01, 2005-05-03, 2005-01-02, 2005-01-01.
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 mark-1961,
so the above would result in 2005-01-01, 2005-01-02, 2005-07-01, 2005-05-03so 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 2005-01-01, 2005-01-02, 2005-05-03, 2005-07-01.
If you want to descend by month, then the result should be 2005-07-01, 2005-05-03, 2005-01-02, 2005-01-01.
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