cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div style="float:left; width:49%; border:1px dashed gray;">
	<h1>Sırasız Dizi</h1>
	<div id="sirasiz" style="">
		
	</div>
</div>
<div style="float:left; width:49%; border:1px dashed gray;">
	<h1>Adede göre sıralı dizi</h1>
	<h2 style="float:left; width:50%;">ASC</h2>
	<h2 style="float:left; width:50%;">DESC</h2>

	<div id="asc" style="float:left; width:50%;">
		
	</div>
	<div id="desc" style="float:left; width:50%;">
		
	</div>
</div>

            
          
!
            
              
			function listArray(arr,order){
			
				// dizideki tekrar eden elemanları sayı adedine toplayıp yeni obj olusturuyoruz
				var itemCount = [];
				arr.forEach(function (x) { itemCount[x] = (itemCount[x] || 0) + 1; });
				
				// olusturdugumuz objeyi ters siralamak icin diziye donusturuyoruz.
				var countsSortable = [];
				for (var i in itemCount) {
					countsSortable.push([ itemCount[i],i])
				}
						
				countsSortable.sort(function (a, b) {
					if(order === 'desc')
					{
						return b[0] - a[0];
					} else {
						return a[0] - b[0];
					}
				});
				
				return countsSortable;
					
			}
			
			var fruits = ["Karpuz","Armut","Ekşi elma","Limon","Armut","Çilek","Çilek","Karpuz","Kiraz","Greyfurt","Beyaz üzüm","Muz","Greyfurt","Karpuz","Muz","Portakal","Nar","Karpuz","Armut","Kara üzüm","Greyfurt","Çilek","Greyfurt","Beyaz üzüm","Muz","Muz","Greyfurt","Muz","Greyfurt","Çilek","Muz","Armut","Nar","Çilek","Armut","Karpuz","Çilek","Elma","Portakal","Nar","Nar","Karpuz","Greyfurt","Karpuz","Greyfurt","Çilek","Beyaz üzüm","Karpuz","Nar","Ekşi elma","Ekşi elma","Nar","Ekşi elma","Ekşi elma","Ekşi elma","Muz","Karpuz","Limon","Nar","Armut","Ekşi elma","Greyfurt","Beyaz üzüm","Armut","Kara üzüm","Muz","Ekşi elma","Portakal","Muz","Karpuz","Muz","Beyaz üzüm","Karpuz","Kara üzüm","Kiraz","Çilek","Elma","Beyaz üzüm","Beyaz üzüm","Beyaz üzüm","Armut","Elma","Portakal","Kara üzüm","Kiraz","Limon","Kiraz","Nar","Ekşi elma","Karpuz","Çilek","Çilek","Ekşi elma","Kiraz","Elma","Greyfurt","Çilek","Kara üzüm","Armut","Karpuz"];
			
			//yazdirma
			document.getElementById('sirasiz').innerHTML = fruits.join("<br>");
			document.getElementById('asc').innerHTML = listArray(fruits,'asc').join("<br>");
			document.getElementById('desc').innerHTML = listArray(fruits,'desc').join("<br>");
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console