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

本站现有博文333篇,共被浏览913631

本站已经建立2616天!

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