<BlockSwitcher>

<Block name="Java">

```java
Amplify.DataStore.query(Post.class,
    Where.sorted(Post.RATING.ascending(), Post.TITLE.descending()),
    posts -> {
        while (posts.hasNext()) {
            Post post = posts.next();
            Log.i("MyAmplifyApp", "Title: " + post.getTitle());
        }
    },
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure)
);
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
Amplify.DataStore.query(Post::class.java,
    Where.sorted(Post.RATING.ascending(), Post.TITLE.descending()),
    { posts ->
        while (posts.hasNext()) {
            val post = posts.next()
            Log.i("MyAmplifyApp", "Title: ${post.title}")
        }
    },
    { Log.e("MyAmplifyApp", "Query failed", it) }
)
```

</Block>

<Block name="Kotlin - Coroutines">

```kotlin
Amplify.DataStore
    .query(Post::class,
        Where.sorted(Post.RATING.ascending(), Post.TITLE.descending())
    )
    .catch { Log.e("MyAmplifyApp", "Query failed", it) }
    .collect { Log.i("MyAmplifyApp", "Title: ${it.title}") }
```

</Block>

<Block name="RxJava">

```java
RxAmplify.DataStore.query(Post.class,
    Where.sorted(Post.RATING.ascending(), Post.TITLE.descending()))
    .subscribe(
        post -> Log.i("MyAmplifyApp", "Post: " +  post),
        failure -> Log.e("MyAmplifyApp", "Query failed.", failure)
    );
```

</Block>

</BlockSwitcher>