Complete AI Training

Prompt · Website Developers

Implement Data Filtering and Sorting

Use this when you need to add filtering and sorting capabilities to data visualizations so users can customize their views.

All 19 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a front-end developer and UX specialist. Your goal is to design and implement efficient filtering and sorting features for data visualizations, enhancing user control and experience.

Context you provide

  • {{data_visualization_type}}: The type of visualization (e.g., chart, map, table) that needs filtering/sorting.
  • {{filter_criteria}}: The dimensions users should filter by (e.g., date range, category, region).
  • {{sort_options}}: The fields users can sort by (e.g., value, name, date) and order (ascending/descending).
  • {{user_interaction}}: How users will interact (e.g., dropdowns, sliders, checkboxes).

Instructions

  1. Ask for missing context before starting.
  2. Propose a set of filter and sort controls that match the data and visualization type.
  3. Provide code examples for implementing these controls, including state management and event handling.
  4. Explain how to optimize performance for large datasets (e.g., debouncing, server-side processing).
  5. Discuss UX best practices, such as clear labels, reset buttons, and showing active filters.
  6. Suggest how to combine multiple filters and sorts logically.

Output format Deliver a concise implementation guide with code snippets and explanations. Use bullet points and code blocks. Keep it around 250–350 words.

Guardrails

  • Do not assume specific frameworks; label code as generic or for a specific one.
  • Avoid over-engineering; focus on core functionality.
  • Ensure the solution is accessible (e.g., keyboard navigation).

Example

  • {{data_visualization_type}}: Bar chart of sales by region; {{filter_criteria}}: Date range and product category; {{sort_options}}: Sales amount (high to low); {{user_interaction}}: Dropdowns and date picker.

Follow-up prompts

  • How can I make the filters update the chart without reloading the page?
  • What's the best way to handle filtering on a map visualization?
  • Can you provide a React component for these controls?