Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; "subject:' ": 0.07; 'subject:help': 0.08; 'builtin': 0.09; 'counting': 0.09; 'friday,': 0.09; 'subject:using': 0.09; "'n'": 0.16; '24,': 0.16; 'collections': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject: \n ': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'sort': 0.25; 'header:In-Reply- To:1': 0.27; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '25,': 0.31; 'anyone': 0.31; 'figure': 0.32; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'are,': 0.36; 'list': 0.37; 'received:209': 0.37; 'easily': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'email addr:gmail.com': 0.63; 'note:': 0.66; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GJe6Fbw+h5vS4YVqmOxXf3Su5DmHJvnWB6mlq20xQWc=; b=F8E2JArHNUZAEDyXPpQMeVorI1zK9BnnKwV/AUMAb1nBdyZucA/O7cffyYHpyHsDci AeDxXUBVandAa77ysQrq5BUWSZjslJv/wrSg2YrtZ6WUH4PLToo1unwZ9TZqBbFzatRA zC96jXg76fDI3XkNJpUsB/M0nPo5BEadldljlWMw56Zr0uBWSCxiWO6e5PsK0ZZFhf5K LjrqvHZs46rqOFe8suHFGsqs0AhKa3OLd7PSd652A92LXWsaVYU7sBLkbaKNbhQXfuCC VMOREDS3GKCkHzyZ65U8rQgHTZG2AqPkCf1a49ESzSONYI3SdfOGPCa/D1HqqY/1+7d8 hn/A== MIME-Version: 1.0 X-Received: by 10.52.89.234 with SMTP id br10mr8777328vdb.52.1369459442093; Fri, 24 May 2013 22:24:02 -0700 (PDT) In-Reply-To: <78192328-b31b-49d9-9cd6-ec742c092a29@googlegroups.com> References: <78192328-b31b-49d9-9cd6-ec742c092a29@googlegroups.com> Date: Sat, 25 May 2013 15:24:01 +1000 Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369459444 news.xs4all.nl 15959 [2001:888:2000:d::a6]:49554 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45962 On Sat, May 25, 2013 at 3:15 PM, wrote: > On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote: >> i need to write a code which can sort the list in order of 'n' without use builtin functions >> >> can anyone help me how to do? > > Note: > the list only contains 0's,1's,2's > need to sort them in order of 'n' In that case, you're not really ordering them, you're counting them. Look at the collections module; you can very easily figure out how many of each there are, and then reconstruct the list afterward. ChrisA