# How to sort a set of ciphertexts?

**URL:** <https://openfhe.discourse.group/t/how-to-sort-a-set-of-ciphertexts/682>\
**Category:** FHE Questions\
**Created:** [July 2, 2023, 8:40am UTC](https://openfhe.discourse.group/t/how-to-sort-a-set-of-ciphertexts/682 "2023-07-02T08:40:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://openfhe.discourse.group/u/Joseph)\
**Post date:** [July 2, 2023, 8:40am UTC](https://openfhe.discourse.group/t/how-to-sort-a-set-of-ciphertexts/682/1 "2023-07-02T08:40:20Z")

</div>

Hello there, I wonder if there exists an efficient algorithm that supports sorting a set of homomorphic ciphertexts (such as BFV, CKKS, or FHEW).

Thanks!

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [July 3, 2023, 12:20am UTC](https://openfhe.discourse.group/t/how-to-sort-a-set-of-ciphertexts/682/2 "2023-07-03T00:20:31Z")

</div>

Sorting would require comparison which is not straightforward in FHE. Please review the literature to learn more about how to do this operation with FHE. Here are some resources you can begin with:

1. [Large-Precision Homomorphic Sign Evaluation using FHEW/TFHE Bootstrapping](https://eprint.iacr.org/2021/1337)
2. [PEGASUS: bridging polynomial and non-polynomial evaluations in homomorphic encryption](https://ieeexplore.ieee.org/abstract/document/9519408/)
3. [EfficientSortingofHomomorphicEncrypted Datawithk-waySortingNetwork](https://eprint.iacr.org/2021/551.pdf)
4. [DepthOptimizedEfficientHomomorphicSorting](https://research.sabanciuniv.edu/id/eprint/28301/1/conf02_main.pdf)
