الفرق بين المراجعتين ل"Kotlin/collections/sortDescending"

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
ط
 
(5 مراجعات متوسطة بواسطة 3 مستخدمين غير معروضة)
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: الدالة <code>sortDescending()‎</code> في لغة Kotlin}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: الدالة <code>sortDescending()‎</code> في Kotlin}}</noinclude>
تقوم الدالة<code>sortDescending()‎</code> بترتيب  [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها تنازليًا.  
+
ترتِّب الدالة <code>sortDescending()‎</code> [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|القائمة المتغيرة]] (MutableList) التي استُدعيت معها تنازليًّا. 
 
 
 
==البنية العامة==
 
==البنية العامة==
يمكن استدعاء الدالة  <code>sortDescending()‎</code> عبر  [[Kotlin/Array|المصفوفات]]: <nowiki/><nowiki/><syntaxhighlight lang="kotlin">
+
يمكن استدعاء الدالة <code>sortDescending()‎</code> مع [[Kotlin/Array|المصفوفات]] [[kotlin/MutableList|والقوائم المتغيرة]]: <syntaxhighlight lang="kotlin">
 
fun <T : Comparable<T>> Array<out T>.sortDescending()  
 
fun <T : Comparable<T>> Array<out T>.sortDescending()  
 
fun ByteArray.sortDescending()  
 
fun ByteArray.sortDescending()  
سطر 12: سطر 11:
 
fun DoubleArray.sortDescending()  
 
fun DoubleArray.sortDescending()  
 
fun CharArray.sortDescending()  
 
fun CharArray.sortDescending()  
</syntaxhighlight>يمكن<nowiki/><nowiki/> استدعاء الدالة  <code>sortDescending()‎</code> عبر  كائن من النوع <code>[[kotlin/MutableList|MutableList]]</code>:<nowiki/><nowiki/><syntaxhighlight lang="kotlin">
+
 
 
fun <T : Comparable<T>> MutableList<T>.sortDescending()  
 
fun <T : Comparable<T>> MutableList<T>.sortDescending()  
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 
==أمثلة==
 
==أمثلة==
===استخدام الدالة <code>()sortDescending</code> مع المصفوفات===
+
استعمال الدالة <code>()sortDescending</code> لترتيب عناصر مصفوفة تنازليًّا:<syntaxhighlight lang="kotlin">
تعرف الشيفرة الآتية  <nowiki/>[[Kotlin/Array|مصفوفة]]<nowiki/>باسم <code>array</code> مكونة من ستة عناصر باستخدام الدالة <code>()arrayOf‎</code>، ثم تستخدم الدالة<code>()sortDescending</code>  على <code>array</code> لترتيبه تنازليًا، ثم تطبع الناتج:<syntaxhighlight lang="kotlin">
 
 
import java.util.Arrays
 
import java.util.Arrays
  
 
fun main(args: Array<String>) {
 
fun main(args: Array<String>) {
val array = arrayOf(1, 9, -3, 7, 5, 6)
+
    val array = arrayOf(1, 9, -3, 7, 5, 6)
array.sortDescending()  
+
    array.sortDescending()
      
+
 
print (Arrays.toString(array)) // [9, 7, 6, 5, 1, -3]
+
     print(Arrays.toString(array)) // [9, 7, 6, 5, 1, -3]
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
==أنظر أيضًا==
+
==انظر أيضًا==
*<code>[[Kotlin/collections/sortBy|sortBy()]]</code>: تقوم بترتيب  [[Kotlin/Array|المصفوفة]] أو [[Kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها وفقًا للقيم التي تعيدها الدالة المُمرّرة . 
+
*الدالة <code>[[Kotlin/collections/sort|sort()]]</code>‎ : ترتب [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|القائمة المتغيرة]] (MutableList) التي استُدعيت معها تصاعديًّا.
 
+
*الدالة <code>[[Kotlin/collections/sortBy|sortBy()]]</code>‎ : ترتب عناصر [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|القائمة المتغيرة]] (MutableList) التي استُدعيت معها تصاعديًّا وفقًا للقيم التي تعيدها الدالة المُمرّرة إليها عند تطبيقها على كل عنصر. 
* <code>[[Kotlin/collections/sort|sort()]]</code>‎ : تقوم بترتيب <nowiki/>[[Kotlin/Array|المصفوفة]] أو اللائحة المتغيرة (<code>MutableList</code>) التي استُدعيت عبرها. 
+
* الدالة <code>[[Kotlin/collections/sortByDescending|sortByDescending()‎]]</code>: ترتِّب عناصر [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|القائمة المتغيرة]] (MutableList) التي استُدعيت معها تنازليًّا وفقًا للقيم التي تعيدها الدالة المُمرّرة إليها عند تطبيقها على كل عنصر
*
+
*الدالة <code>[[Kotlin/collections/sortWith|sortWith()‎]]</code>: ترتِّب جميع عناصر [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|القائمة المتغيرة]] (MutableList) التي استُدعيت معها أو جزءًا محدَّدًا منها تنازليًا وفقًا للمُقارن المُمرّر إليها.
 +
* الدالة <code>[[Kotlin/collections/sortedArrayDescending|sortedArrayDescending()]]</code>: ترتِّب جميع عناصر <nowiki/>[[Kotlin/Array|المصفوفة]] التي استُدعيت معها تنازليًّا ثمَّ تضع الناتج في مصفوفة جديدة.
 +
* الدالة <code>[[Kotlin/collections/sortedDescending|sortedDescending()‎]]</code>: ترتِّب جميع عناصر <nowiki/>[[Kotlin/Array|المصفوفة]] أو المجموعة التكرارية التي استُدعيت معها تنازليًّا ثمَّ تضع الناتج في قائمة.
  
 
==مصادر==
 
==مصادر==
*[https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sort-descending.html الدالة  sortDescending()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
+
*[https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sort-descending.html صفحة الدالة sortDescending()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
 
[[تصنيف:Kotlin]]
 
[[تصنيف:Kotlin]]
[[تصنيف:Kotlin Functions]]
+
[[تصنيف:Kotlin Function]]
 +
[[تصنيف:Kotlin Collection]]

المراجعة الحالية بتاريخ 11:07، 8 سبتمبر 2018

ترتِّب الدالة sortDescending()‎ المصفوفة أو القائمة المتغيرة (MutableList) التي استُدعيت معها تنازليًّا. 

البنية العامة

يمكن استدعاء الدالة sortDescending()‎ مع المصفوفات والقوائم المتغيرة

fun <T : Comparable<T>> Array<out T>.sortDescending() 
fun ByteArray.sortDescending() 
fun ShortArray.sortDescending() 
fun IntArray.sortDescending() 
fun LongArray.sortDescending() 
fun FloatArray.sortDescending() 
fun DoubleArray.sortDescending() 
fun CharArray.sortDescending() 

fun <T : Comparable<T>> MutableList<T>.sortDescending()

أمثلة

استعمال الدالة ()sortDescending لترتيب عناصر مصفوفة تنازليًّا:

import java.util.Arrays

fun main(args: Array<String>) {
    val array = arrayOf(1, 9, -3, 7, 5, 6)
    array.sortDescending()

    print(Arrays.toString(array)) // [9, 7, 6, 5, 1, -3]
}

انظر أيضًا

مصادر