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

本站现有博文327篇,共被浏览833645

本站已经建立2538天!

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