Skip to content

Add TagSort (Index Sort) algorithm with tests#7366

Closed
saidyanak wants to merge 1 commit intoTheAlgorithms:masterfrom
saidyanak:add-tag-sort
Closed

Add TagSort (Index Sort) algorithm with tests#7366
saidyanak wants to merge 1 commit intoTheAlgorithms:masterfrom
saidyanak:add-tag-sort

Conversation

@saidyanak
Copy link
Copy Markdown

Description

Adds Tag Sort (also known as Index Sort or Dictionary Sort) to the sorts package.

Algorithm Overview

Tag Sort creates an array of indices (tags) and sorts those indices based on corresponding values in the original array. This is useful when the original positions of elements need to be preserved after sorting.

Complexity

  • Time Complexity: O(n log n)
  • Space Complexity: O(n)

Features

  • Implements SortAlgorithm interface
  • Additional getSortedTags() method to retrieve sorted indices without modifying the original array
  • Full test coverage (empty, single element, duplicates, negatives, strings, already sorted, reverse sorted)

References

Tag Sort (Index Sort) creates an array of sorted indices without modifying
the original array. Useful when original positions need to be preserved.
Time complexity: O(n log n), Space complexity: O(n).
@github-actions
Copy link
Copy Markdown

This pull request has been automatically closed because its workflows or checks failed and it has been inactive for more than 14 days. Please fix the workflows and reopen if you'd like to continue. Merging from main/master alone does not count as activity.

@github-actions github-actions bot closed this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant