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

本站现有博文335篇,共被浏览937557

本站已经建立2648天!

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