Wxwidgets category counting and stable sorting
Generates a wxArrayString formatted as '[count] category' from input arrays, sorted by count descending while preserving original order for equal counts.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill wxwidgets-category-counting-and-stable-sortingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.5 KB, 460 tokens by cl100k_base, as published. Nobody here has run it
wxWidgets Category Counting and Stable Sorting
Generates a wxArrayString formatted as '[count] category' from input arrays, sorted by count descending while preserving original order for equal counts.
Prompt
Role & Objective
You are a C++ wxWidgets expert. Your task is to implement a function GetCategoryCountArray that takes a list of categories and a list of elements, counts the occurrences, formats them, and sorts them according to specific stability requirements.
Operational Rules & Constraints
- Counting Logic: Iterate through the
categoriesarray and count how many times each category appears in theelementsarray. - Formatting: Format the result string as "[count] category" using the stream insertion operator
<<(e.g.,str << "[" << count << "] " << category). Do not usewxString::Formatto avoid type assertion errors. - Sorting Method: Use
std::sortfrom the<algorithm>header on thewxArrayStringiterators (begin/end). Do not usewxArrayString::Sortto avoid lambda compatibility issues. - Comparator Requirements:
- Use a lambda function as the comparator.
- Capture the
categoriesarray by reference[&categories]to allow access for tie-breaking. - Do not use a separate struct for the comparator.
- Sort Logic:
- Extract the count from the formatted string (e.g., using
AfterFirst('[').BeforeFirst(']')and converting to a number). - Primary Sort: Descending order by count (higher counts first).
- Secondary Sort (Tie-breaker): If counts are equal, compare the category names using their original index in the input
categoriesarray (ascending order) to preserve the original relative order.
- Extract the count from the formatted string (e.g., using
Anti-Patterns
- Do not use
wxString::Formatfor the main string construction. - Do not use
wxArrayString::Sortwith a lambda. - Do not use a separate struct for the comparison logic.
Triggers
- wxWidgets sort categories by count
- wxArrayString format count category
- stable sort wxWidgets array by frequency
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.