Question: I have tried the other questions like this but none seem to match it. I want it to repeat if the user enters Y after the numbers are sorted in the console.
Here is the code:

```
package compsorter;
import java.util.Scanner;
public class Ascending_Order 
{
    public static void main(String[] args) 
    {
    int n, temp;
    Scanner s = new Scanner(System.in);
    System.out.print("Enter no. of elements you want in array:");
    n = s.nextInt();
    int a[] = new int[n];
    System.out.println("Enter all the elements:");

    for (int i = 0; i < n; i++) 
    {
        a[i] = s.nextInt();
    }
    for (int i = 0; i < n; i++) 
    {
        for (int j = i + 1; j < n; j++) 
        {
            if (a[i] > a[j]) 
            {
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
    System.out.print("In Ascending Order:");
    for (int i = 0; i < n - 1; i++) 
    {
        System.out.print(a[i] + ",");
    }
    System.out.print(a[n - 1]);
    s.close();
}
}

```

Thanks!

Answer: 
The only problem with the recursive solution is the stack over flow problem. A way to do it without recursion is

```
Observable<ArtistsCursorPager> allPages = Observable.defer(() ->
{
    BehaviorSubject<Object> pagecontrol = BehaviorSubject.create("start");
    Observable<ArtistsCursorPager> ret = pageControl.asObservable().concatMap(aKey ->
    {
        if (aKey != null && aKey.equals("start")) {
            return Observable.getFollowedArtists(50).doOnNext(page -> pagecontrol.onNext(page.cursors.after));
        } else if (aKey != null && !aKey.equals("")) {
            return Observable.getFollowedArtists(50,aKey).doOnNext(page -> pagecontrol.onNext(page.cursors.after));
        } else {
            return Observable.<ArtistsCursorPager>empty().doOnCompleted(()->pagecontrol.onCompleted());
        }        
    });
    return ret;
});

```

See the solutions to [this question](https://stackoverflow.com/questions/37326380/paginate-observable-results-without-recursion-rxjava).
There´s not unique way to do this. 
In my case what I did was make some recursive calls using `mergeWith`

```
private Observable<String> getUUIDsQuery(JsonObject response) {
    final Observable<String> uuidsQuery = createUuidsQuery(response);
    return hasPagination(response) ? paginate(response, uuidsQuery) : uuidsQuery;
}

   private Observable<String> paginate(JsonObject response, Observable<String> uuidsQuery) {
    return request(getPaginationUri(response))
            .flatMap(res -> uuidsQuery.mergeWith(getUUIDsQuery(res)));
}

```

Hope to help you to give you an idea.