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

本站现有博文337篇,共被浏览961676次

本站已经建立2673天!

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