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

本站现有博文336篇,共被浏览948047

本站已经建立2659天!

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