Skip to content

Support for sorting simple arrays (integers/strings) with SortArray (Fixes #4929) #4943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ranzyblessings
Copy link

  • Added methods byValueAscending() and byValueDescending() to the SortArray class
    to support sorting simple array types (e.g., integers, strings) in ascending and descending order.
  • Updated tests to verify the correct functionality of sorting arrays by value.
  • Refactored SortArray to handle sorting of simple types without requiring a property for sorting.

For more details, refer to: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/

Signed-off-by: Ranzy Blessings ranzyblessings.inbox@gmail.com

…ray (Fixes spring-projects#4929)

- Added methods `byValueAscending()` and `byValueDescending()` to the SortArray class
  to support sorting simple array types (e.g., integers, strings) in ascending and descending order.
- Updated tests to verify the correct functionality of sorting arrays by value.
- Refactored SortArray to handle sorting of simple types without requiring a property for sorting.

For more details, refer to: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/

Signed-off-by: Ranzy Blessings <ranzyblessings.inbox@gmail.com>
@ranzyblessings
Copy link
Author

Hello team,

I’ve addressed the issue with sorting simple arrays (integers/strings) in PR #4943. The fix includes the addition of the byValueAscending() and byValueDescending() methods, along with updated tests to ensure correct functionality.

Please don’t hesitate to reach out if any further modifications or adjustments are needed. I’m happy to make any necessary changes.

Best regards,
Ranzy Blessings

Fixes #4929

@christophstrobl
Copy link
Member

Thank you @ranzyblessings! we'll have a look.

@ranzyblessings
Copy link
Author

Thanks @christophstrobl! Let me know if anything needs adjusting. Also, just a heads-up on the @since 4.x (TBD) I wasn't sure which version to use, but I included it to stay consistent with other methods. I also haven’t added full documentation (like the Spring docs) yet, as I’ll wait for your feedback before finalizing that based on your documentation style.

ranzyblessings added a commit to ranzyblessings/spring-data-mongodb that referenced this pull request Apr 11, 2025
…ixes spring-projects#4929) spring-projects#4943 - Removed unnecessary whitespaces

- Added methods byValueAscending() and byValueDescending() to the SortArray class
to support sorting simple array types (e.g., integers, strings) in ascending and descending order.
- Updated tests to verify the correct functionality of sorting arrays by value.
- Refactored SortArray to handle sorting of simple types without requiring a property for sorting.
- Removed unnecessary whitespaces and formatting changes to ensure clean, readable code.

For more details, refer to: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/

Signed-off-by: Ranzy Blessings <ranzyblessings.inbox@gmail.com>
…h SortArray (Fixes spring-projects#4929) to cleanup excessive formatting"

This reverts commit 0422055.

Signed-off-by: Ranzy Blessings <ranzyblessings.inbox@gmail.com>
…ixes spring-projects#4929) spring-projects#4943 - Removed unnecessary whitespaces

- Added methods byValueAscending() and byValueDescending() to the SortArray class
to support sorting simple array types (e.g., integers, strings) in ascending and descending order.
- Updated tests to verify the correct functionality of sorting arrays by value.
- Refactored SortArray to handle sorting of simple types without requiring a property for sorting.
- Removed unnecessary whitespaces and formatting changes to ensure clean, readable code.

For more details, refer to: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/

Signed-off-by: Ranzy Blessings <ranzyblessings.inbox@gmail.com>
@ranzyblessings ranzyblessings force-pushed the feature/SDMONGO-4929-sortarray-value-sorting branch from bf38afb to 73f92a6 Compare April 11, 2025 14:55
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants