Github user mateiz commented on the pull request:

    https://github.com/apache/spark/pull/97#issuecomment-37329386
  
    Hi Prashant,
    
    For this feature I think it would be better to use a "key" function instead 
of a boolean flag for the order. So make the API like this:
    ```
    def takeOrdered(self, num, key=None)
    ```
    This will apply `key` to each element if it's not none (e.g. you might pass 
`lambda x: x.name`), sort the elements by that key, and then return the 
smallest num of them.
    
    To implement it, you won't need to modify `heapq` anymore. Just go with 
`PriorityQueue` and add `(key, elem)` pairs into it if the `key` function is 
set, or just `elem` elements into it otherwise. We'll take the cost of 
PriorityQueue locking because it seems to annoying to modify `heapq`.
    
    Matei


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to