BestPromptFinder
HomeCoding › Below is an instruction that describes a task. Write a respo...

Below is an instruction that describes a task. Write a respo...

Coding · General · Coding
58Quality
90%Useful
87Reliability

The prompt

Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Write a function in Python that takes a list of objects and returns a list of those objects sorted by one of their attributes. ### Input: [{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}] ### Output: def sort_by_attr(objects, attr): return sorted(objects, key=lambda item: item[attr]) sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "age")
Find similar in the app →

Why this prompt

Source

Hugging Face

Related Coding prompts

PRD to MVP Technical Plan
Quality 93 · Claude Code
Full-Stack CRUD App Builder
Quality 93 · Claude Code
Legacy Refactor Planner
Quality 93 · Claude Code
Test Suite Generator
Quality 93 · Claude Code
Third-Party API Integration
Quality 93 · Claude Code
Database Schema and Migration
Quality 93 · Claude Code