I try to sort datetime by descending order #340

Open
opened 2025-12-29 18:25:51 +01:00 by adam · 2 comments
Owner

Originally created by @oddukgi on GitHub (Aug 25, 2020).

I make variable

     let fetchingItems =  [ { (newDate) -> [DataType] in
        
     return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.veggieConfiguration)
                    .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
        
      },
      {   (newDate) -> [DataType] in
                
           return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.fruitsConfiguration)
                            .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
        
        } ]

DateTime is string type.
I create datetime like "yyyy.MM.dd h:mm:ss a"
I want to show recent data is first.
When time changed 11pm, ordering didn't change.

Originally created by @oddukgi on GitHub (Aug 25, 2020). I make variable ```swift let fetchingItems = [ { (newDate) -> [DataType] in return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.veggieConfiguration) .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate))) }, { (newDate) -> [DataType] in return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.fruitsConfiguration) .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate))) } ] ``` DateTime is string type. I create datetime like "yyyy.MM.dd h:mm:ss a" I want to show recent data is first. When time changed 11pm, ordering didn't change.
Author
Owner

@JohnEstropia commented on GitHub (Aug 25, 2020):

I’m not sure if understand your issue, but fetchAll() returns an array, and the ordering would be fixed during fetch time.

If you want a list that changes ordering dynamically, use ListPublishers or ListMonitors

@JohnEstropia commented on GitHub (Aug 25, 2020): I’m not sure if understand your issue, but `fetchAll()` returns an array, and the ordering would be fixed during fetch time. If you want a list that changes ordering dynamically, use `ListPublisher`s or `ListMonitor`s
Author
Owner

@oddukgi commented on GitHub (Aug 25, 2020):

Ok. I will check ordering works fine at night time.
If didn't work, follow your advice. 🦊

@oddukgi commented on GitHub (Aug 25, 2020): Ok. I will check ordering works fine at night time. If didn't work, follow your advice. 🦊
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#340