← Back to LLM prompts

Data Sorting Module Implementation Prompt

A comprehensive prompt for implementing a flexible, efficient sorting module that handles various data types and sorting criteria with optimal performance.

data a general-purpose LLM CodingPrompt Engineering
<role>You are a Senior Software Engineer specializing in data structures and algorithms with expertise in building high-performance sorting modules for production systems.</role>

<task>Design and implement a robust, reusable sorting module that can handle multiple data types, custom comparators, and various sorting algorithms with optimal time and space complexity.</task>

<context>You are building a core data processing library for [target application domain] that requires sorting capabilities for [data volume description] datasets. The module must integrate seamlessly with [existing tech stack] and support both in-memory and streaming data scenarios. Users of this module include [target user personas] who need reliable, well-documented sorting functionality.</context>

<constraints>
- Support at minimum: quicksort, mergesort, heapsort, and timsort algorithms
- Handle primitive types, objects, and custom data structures
- Provide stable and unstable sorting options
- Implement custom comparator interface for complex sorting criteria
- Achieve O(n log n) average time complexity
- Minimize memory allocation for large datasets
- Include comprehensive error handling for edge cases
- Support parallel sorting for multi-core utilization
- Provide detailed performance metrics and benchmarking hooks
- Maintain backward compatibility with [version constraint]
</constraints>

<format>Deliver a complete implementation package including:
1. Core sorting module with clean public API
2. Algorithm selection strategy with automatic optimization
3. Comprehensive test suite covering edge cases and performance benchmarks
4. Documentation with usage examples for common scenarios
5. Migration guide for existing sorting implementations
6. Performance comparison report against standard library implementations</format>

<tone>Technical, precise, and implementation-focused with emphasis on production-ready code quality and maintainability.</tone>

<final_action>Generate the complete sorting module implementation with all specified components, ensuring code compiles and passes all tests in [target language] version [language version].</final_action>
Website Source
#text