# Basic sort/limit option for post\_stream

**URL:** https://meta.discourse.org/t/basic-sort-limit-option-for-post-stream/60431
**Category:** Feature
**Created:** [April 4, 2017, 4:38pm UTC](https://meta.discourse.org/t/basic-sort-limit-option-for-post-stream/60431 "2017-04-04T16:38:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MittchoBaroco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittchobaroco/32/121105_2.png) [@MittchoBaroco](https://meta.discourse.org/u/MittchoBaroco)
#### Post date: [April 4, 2017, 4:38pm UTC](https://meta.discourse.org/t/basic-sort-limit-option-for-post-stream/60431/1 "2017-04-04T16:38:50Z")

</div>

Hi !

I was trying to fetch all the posts related to a topic and order them by created\_date so the latest will be displayed first.

we are using the Ruby Gem.

our solution was to query the topic first, reverse the stream and fetch the 10 first ids, after we did an other query to fetch the correct posts using the **topic\_post** method.

> topic = project.get\_ask\_topic

> posts\_id = topic[“post\_stream”][“stream”].reverse[0..10]  
> posts = DISCOURSE\_CLIENT.topic\_posts(project.ask\_topic\_id, @posts\_id)  
> posts = posts[“post\_stream”][“posts”].reverse

I am just wondering why the API doesn’t have a possible :order params and :limit params to fetch to correct data at once.

I’am happy to help to implement that !
