AutoSkill 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.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/wxwidgets-category-counting-and-stable-sorting" ~/.claude/skills/ecnu-icalk-autoskill-wxwidgets-category-counting-and-stable-sorting && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/wxwidgets-category-counting-and-stable-sorting/SKILL.mdsource content
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
array and count how many times each category appears in thecategories
array.elements - Formatting: Format the result string as "[count] category" using the stream insertion operator
(e.g.,<<
). Do not usestr << "[" << count << "] " << category
to avoid type assertion errors.wxString::Format - Sorting Method: Use
from thestd::sort
header on the<algorithm>
iterators (begin/end). Do not usewxArrayString
to avoid lambda compatibility issues.wxArrayString::Sort - Comparator Requirements:
- Use a lambda function as the comparator.
- Capture the
array by referencecategories
to allow access for tie-breaking.[&categories] - Do not use a separate struct for the comparator.
- Sort Logic:
- Extract the count from the formatted string (e.g., using
and converting to a number).AfterFirst('[').BeforeFirst(']') - 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
array (ascending order) to preserve the original relative order.categories
- Extract the count from the formatted string (e.g., using
Anti-Patterns
- Do not use
for the main string construction.wxString::Format - Do not use
with a lambda.wxArrayString::Sort - 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