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

本站现有博文323篇,共被浏览802901

本站已经建立2502天!

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