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

本站现有博文338篇,共被浏览966581次

本站已经建立2679天!

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