सीधे मुख्य सामग्री पर जाएं

Python में Sorting Dictionary क्या है ( Python Sorting Dictionary in Hindi )

दोस्तों Python Tutorial में अभी तक हमें पढ चुके हैं की Python Collection क्या है, Dictionary क्या है और आज हमे देखगे की Python में Sorting Dictionary क्या है ( Python Sorting Dictionary in Hindi ) तो चलाइए इस विस्तार में समझते हैं 

INTRODUCTION


Python में dictionary एक collection हैं जिसमें data key और value की form में Store रहते हैं सभी keys अपनी-अपनी values के साथ associated होती हैं।

Python में by-default dictionary unordered होती हैं लेकिन कभी-कभी ऐसा भी हो सकता है की हमे queries को आसान बनाने के लिए dictionary को sort करना पड़े सकता है। 


Dictionary को sort क्यो करते हैं (NEED OF SORTING DICTIONARY ) 


  1. Sorted data को हम efficiently analyze कर सकते हैं। 
  2. Sorted dictionary में complex operations आसानी से perform किए जा सकते हैं।
  3. Sorted data complexity को कम करता है तथा quires को fast और efficient बनाता हैं इसलिए जब हम बहुत बडे data के साथ काम कर रहे तो sorting करना बहुत जरूरी होता हैं।


Dictionary को sort करने के तरीके (WAYS TO SORTING DICTIONARY) 


1.Sorting by keys and values

Python में dictionary को sort करने के लिए built-in key() और value() function प्रदान करता है। 

यह argument के रूप में किसी भी iterable को लेता है और key की एक list return करता है। dictionary को ascending order में sort करने के लिए हम keys का use करते।

Example-


Python sorting dictionary, sorting dictionary, sort dictionary in python


Output-
Python sorting dictionary, sorting dictionary, sort dictionary in python


2.Sorting Algorithm 

Dictionary को sort करने की बहुत सी sorting algorithm हैं। 

Example-

Python sorting dictionary, sorting dictionary, sort dictionary in python


Output-

Python sorting dictionary, sorting dictionary, sort dictionary in python


3.Reverse the sorted order

Dictionary को reverse argument की help से reverse भी किया जा सकता है। 

Example-

Python sorting dictionary, sorting dictionary, sort dictionary in python


Output-

Python sorting dictionary, sorting dictionary, sort dictionary in python


आज हमने क्या सीखा ?

दोस्तो आज हमने Python में Sorting Dictionary

क्या है ( Python Sorting Dictionary in Hindi )  के बारे मे सीखा मुझे आश है की आपको यह समझे मे आ गया होगा।

 मेरी हमेशा से यह कोशिश रहती है की मै सभी लोगो को computer व coding से related सारे जानकारी  आसानी से समझा सुक। यदि आपको कुछ इस post से कुछ doubt हो या फिर कोई अन्य जानकारी जाननी हो तो आप comment कर हमसे पूछ सकते है।


यदि आपको हमारे द्वारा दी गई जानकारी पसंद आए तो आप हमारे blog को अपने friends, relatives आदि को share करे ताकि सभी लोगे इसका लाभ ले सके।

आपको यह post कैसी लगी comment करे बताइए ताकि आपके द्वारा दी गए सुधार व विचार से हम अपने content मे सुधार कर सके। और कृपया इस को post social  networks पर जरूर share करे।

धन्यवाद



टिप्पणियाँ

एक टिप्पणी भेजें

इस ब्लॉग से लोकप्रिय पोस्ट

Python control statements क्या है ( What is Python control statement in hindi )

Python tutorial में आज हम जानगे की Python control statements क्या है ( What is Python control statement in hindi ) किसी भी programming language में Control statement बहुत ही महत्वपूर्ण होता इसके बिना programming नहीं की जा सकती है आइए इस विस्तार में समझते हैं की Python control statements क्या है ( What is Python control statement in hindi )  INTRODUCTION   Program में condition के अनुसार statement को control करने के लिए control statement का उपयोग किया जाता है। इस हमे decision  making statement भी कहते हैं 1) if Statement- if statement में किसी condition को check किया जाता है यदि condition true होती हैं तो if block मे लिखी statement execute हो जाते हैं और यदि condition false है तो if के block में लिख code को ignore कर दिया जाता है। Syntax- if condition:     Statements Example- a = 10 b = 20 if b > a:   print("b is greater than a") Output- b is greater than a 2) if-else- if-else statement भी if की तरह होता है difference बस इतना है की इसम...

Python environment variable क्या है? ( What is Python environment variables in hindi )

दोस्तों Python के tutorial मे आगे बढ़ते हुए आज हमे सीखे की Python environment variable क्या है? ( What is Python environment variables in hindi ) तो चलाइए इस विस्तार में समझते हैं  Introduction   Environment variable एक dynamic object होता है जिसमे editable value होती है इसका use computer मे एक या एक से ज्यादा software करते हैं environment variable का use program को यह जानने में help करता है की file को किस directory मे store किया जाए। temporary file को कहा store किया जाता file को कहाँ से access किया जाए आदि। Different Environment variable  PYTHONPATH- यह PATH के समान ही होता है। यह Interpreter को बताता है की program में import की गयी module file को कहाँ locate करना है। PYTHONPATH कभी-कभी Python installer द्वारा भी प्रस्तुत किया जाता है।  PYTHONSTARTUP-  यह उस file के path को store करता है जो Python Source कोड को initialize करती है। जब भी interpreter start होता है, तब यह execute होता है। यह PYTHONPATH को modify या utilities को लोड करने का command अपने पास रखता...

Python Indentation क्या है ( What is Python Indentation in hindi )

  दोस्तो आज हमे जानने की Python Indentation क्या है ( What is Python Indentation in hindi ) और साथ ही हम यह भी देखें की इसे कैसे Create व उपयोग करते हैं। INTRODUCTION Python में indentation को काफी महत्व दिया गया python में indentation का use function class, loop और control statements के लिए किया जाता है python में curl bracket की जगह indentation का use किया जाता है। Program में एक block बहुत सारे statements का Collection होता है। एक block को विशिष्ट उद्देश्य के लिए बनाया जाता है। आधिकाश programming language जैसे C, C++,Java आदि code के block को defineकरने के लिए curl bracket ({ }) का प्रयोग करते हैं लेकिन Python में code के block को indentation से define किया जाता है। सामान्य रूप से Indentation एक whitespace होता है जिसका use एक block को दूसरे Block से अलग करने के लिए किया जाता है। एक code Block (function, loop) indentation से start और श un-indentation पर end होता है। किसी भी program मे कितने भी indentation हो सकते है यह पूरे तरह programmers पर depend होता है। यह बहुत ही महत्वप...