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

本站现有博文339篇,共被浏览1001486次

本站已经建立2711天!

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