Cumulocity-IoT / apama-rxepl

ReactiveX for Apama EPL Created by Global Presales.
Apache License 2.0
0 stars 0 forks source link

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

Open wFxCA7byemMq90cYsywsiVQEd41l12oZRs3IKpI opened 5 years ago

wFxCA7byemMq90cYsywsiVQEd41l12oZRs3IKpI commented 5 years ago

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

4JZbvEYwdcNMGllZTNBYBEj8NWah7EGyyQbVtDk commented 5 years ago

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 >