# 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:** 13

<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 23, 2022, 1:41am UTC](https://forums.unrealengine.com/t/how-to-sort-a-random-datetime-array-from-oldest-to-newest/274128/13 "2022-01-23T01:41:27Z")

</div>

When adding a new save, you just add it to the beginning of the array (index 0):  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/e/be8033f582344e8d256e98ffb7c78a307dfbbc00.png)

And when loading a save, you move the save to the beginning of the array:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/5/655c8d48c567c5495c4cb23e6a5131be3646caca.png)

Here’s what that looks like (displaying time only); notice how it always stays sorted:

[https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/8/f82450e5326bd0abc3b7f1fca93c5e9ce20ac56a.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/8/f82450e5326bd0abc3b7f1fca93c5e9ce20ac56a.mp4)

Also, you can see that the date isn’t even used, so this works without storing the date. All we are doing is moving the save that the player chooses to the top; the sorting happens naturally.

---

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