# How to sort a random DateTime array from oldest to newest?

**URL:** <https://forums.unrealengine.com/t/how-to-sort-a-random-datetime-array-from-oldest-to-newest/274128>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4-27, question\
**Created:** [January 22, 2022, 7:21am UTC](https://forums.unrealengine.com/t/how-to-sort-a-random-datetime-array-from-oldest-to-newest/274128 "2022-01-22T07:21:09Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![midgunner66](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/midgunner66/32/466711_2.png) [@midgunner66](https://forums.unrealengine.com/u/midgunner66)\
**Post date:** [January 22, 2022, 7:49pm UTC](https://forums.unrealengine.com/t/how-to-sort-a-random-datetime-array-from-oldest-to-newest/274128/9 "2022-01-22T19:49:48Z")

</div>

I saw the other thread for this and you’re going to be using this for a save system, right? If you are, then you don’t need to sort anything because all saves are already going to be played in chronological order, so you’ll always know which is the most recent. Basically, the most recent save is just the one that was played last, and the one that was played last is the one that is being played currently (i.e. the one that the player picks).

So all you have to do is put the save that is being playing currently at the top of the array (index 0), and it’ll already be sorted.

> **Example (Newest to Oldest)**
>
> NewGame → Save0  
> SaveArray = {Save0}
> 
> NewGame → Save1  
> SaveArray = {Save1, Save0}
> 
> NewGame → Save2  
> SaveArray = {Save2, Save1, Save0}
> 
> LoadGame → Save0  
> SaveArray = {Save0, Save2, Save1}
> 
> NewGame-\> Save3  
> Save Array = {Save3, Save0, Save2, Save1}
> 
> LoadGame → Save2  
> SaveArray = {Save2, Save3, Save0, Save1}

And to have it oldest to newest, you would either (A) add them at the **end** of the array, or (B) read the array in reverse.

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-sort-a-random-datetime-array-from-oldest-to-newest/274128)._
