EADST

Python: Sort the Dictionary Based on Key or Value

Python: Sort the Dictionary Based on Key or Value

a = { "b": 5, "c": 2,"a": 4, "d": 1}
test_1=sorted(a.items(),key=lambda x:x[0]) # sort the dictionary based on key
print(test_1) # [('a', 4), ('b', 5), ('c', 2), ('d', 1)]
test_2=sorted(a.items(),key=lambda x:x[1]) # sort the dictionary based on value
print(test_2) # [('d', 1), ('c', 2), ('a', 4), ('b', 5)]

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
签证 RL ModelScope CAM 第一性原理 LeetCode TensorFlow Miniforge Github Statistics Hilton Tiktoken Zip TensorRT Streamlit Data Permission 阿里云 torchinfo Cloudreve FP64 Magnet Search Git QWEN Paddle DeepSeek OpenAI VPN Windows printf SQLite Attention Ubuntu 财报 tar 顶会 PIP BTC GPTQ Dataset ONNX Bert 个人博客 logger EXCEL FP16 Math Pytorch SQL Disk OpenCV GoogLeNet hf Docker FlashAttention llama.cpp SPIE BeautifulSoup Website Excel CLAP LLM CV Freesound Paper WebCrawler Michelin Image2Text SAM Conda AI mmap 长期记忆 Clash Tensor Transformers Safetensors PyTorch Template Qwen2 Review XGBoost RAR 飞书 LaTeX Distillation NLTK 论文速读 Qwen2.5 Knowledge Web 音频 v2ray NLP 递归学习法 Mixtral ms-swift 强化学习 OCR icon Augmentation TTS LoRA Card tqdm Nginx git-lfs v0.dev BF16 Color Input Markdown GGML diffusers 净利润 Translation 多进程 Pillow SVR TSV 腾讯云 证件照 Plotly WAN Jetson uWSGI API网关 PyCharm Base64 XML Pandas Shortcut UI scipy Proxy Domain Algorithm Numpy Heatmap Gemma Qwen uwsgi Land Jev COCO Quantization DeepStream Hotel Vim HaggingFace Random Bipartite RGB Tracking API git CEIR Bin Pickle VSCode VGG-16 MD5 Crawler Bitcoin transformers Video 报税 PDB Google 公式 CSV 云服务器 Breakpoint Python 版权 Jupyter Hungarian 图形思考法 关于博主 FP8 Food Harness CUDA Llama 多线程 Anaconda InvalidArgumentError News 论文 Password CTC Rebuttal PDF HuggingFace Ptyhon Use Sklearn ChatGPT CC LLAMA Logo ResNet-50 继承 Plate 搞笑 Claude IndexTTS2 JSON Baidu Agent Animate FP32 Linux 图标 Quantize UNIX Django Datetime Interview GIT FastAPI Vmess 算法题 C++ Firewall NameSilo YOLO 域名 GPT4 自我改进 Diagram
站点统计

本站现有博文340篇,共被浏览1019249次

本站已经建立2719天!

热门文章
文章归档
回到顶部