Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

'sort' needs an example which isn't sorting on simple numbers #59

Open
nigelm187 opened this issue Jan 10, 2019 · 1 comment
Open

'sort' needs an example which isn't sorting on simple numbers #59

nigelm187 opened this issue Jan 10, 2019 · 1 comment

Comments

@nigelm187
Copy link
Contributor

https://github.com/SoftwareAG/apama-rxepl/blob/master/docs/interfaces/IObservable.md#sort

The sort example needs to be extended so show how it would be used when sorting a string or an event element

@rpeach-sag
Copy link
Contributor

Hmm... I'm not sure what I'd put that was simple enough.

action comparator(string left, string right) {
    if (left > right) { // You can compare strings in Epl
        return 1;
    } else {
        return -1;
    }
}

Observable.fromValues(["xyz", "abc"])
    .sort(comparator)
    ....

Is it obvious why this works? Relys on string comparison < or >

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants