Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Web Security TippsAssign temporary administrator roles in the Google Admin console(23.09.2026 um 23:23 Uhr)
•
Sichere ProgrammierungIs GEO only in our heads, or something real?(24.09.2026 um 01:43 Uhr)
•
Sichere ProgrammierungScoped Permission Error in One Code Branch (Capability Evidence First)(24.09.2026 um 01:48 Uhr)
••••••••
Web Security TippsAssign temporary administrator roles in the Google Admin console(23.09.2026 um 23:23 Uhr)
•
Sichere ProgrammierungIs GEO only in our heads, or something real?(24.09.2026 um 01:43 Uhr)
•
Sichere ProgrammierungScoped Permission Error in One Code Branch (Capability Evidence First)(24.09.2026 um 01:48 Uhr)
••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Array Method Sort on Numbers;

First experience with Sort() As a beginner developer learning Javascript, there were a few things I found confusing. During my learning of Javascript Arrays, one of those things was Sort(). Sort was a native array method that would…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




First experience with Sort()



As a beginner developer learning Javascript, there were a few things I found confusing.

During my learning of Javascript Arrays, one of those things was Sort().



General code example of sort method



Sort was a native array method that would take an array, compare each element with the next and automatically sort its elements in ascending order. Simple right? But I had to ask myself, "What is actually happening under the hood?."



Take this example below.



Array of numbers 1 to 10



Console logs arr array after sorting

Here, I have an array of numbers, in which I would then apply the sort method on.

In my mind, I'm thinking, "If every number is sorted in ascending order, why is 10 not at the end of this array?".

Obviously, I have zero clue on what is happening as I have had zero prior experience with programming.

Sort() is not behaving like I'd expect.






Googling



After browsing a few online forums and a couple videos, I felt like I started to understand.



If we use the sort() by itself, with no argument passed into it, the method will sort the elements in the array. But the only issue is, this method will convert the elements it reads into datatype-- strings.



We have to remember that a method will behave like a robot so when it is reading a multi-digit string, it's seeing it as a series of numbers and not as a whole.



As strings, it will compare the Unicode numerical code values of the first character in those string numbers. The number 10's first character is 1 which has a value less than number 2.






Solution



In the midst of googling up a storm on sort(), I came across some solutions to how we can change up how the sort method operates.



Here, I have an array named numbers with its elements in random order but I'd like to sort them in ascending order.



Firstly, as an array method, Sort has () because it can accept an argument. This is what I used to change the method.



Instead of allowing the method to read elements as strings, I passed in a parameter. A function, more specifically. The function itself, will take in comparative parameters, a and b. The function will then return a value and depending on that value, it will determine the order in which the method will sort.



Function taking in a and b parameters

In the example above, we can see the sort() taking in a function which has parameters (a, b) and it will no longer compare a and b as strings but integers, and then it returns the value resulting from a - b.



Now, as I said before, the value will determine the sorting action. But how?



In the code example, a - b, it will subtract b from a.

The resulting value can only be 1 out of 3.




  • Negative number

  • Positive number

  • 0



If a - b results in a number that is negative, a will come before b.

Below, if we see a as 1 and b as 10, the difference would be -9.

So 1 would come before 10.

1 minus 10



Now, if a - b results to a positive number, b will come before a.

If b comes before a, 2 will now be before 10.

10 minus 2



Lastly, if a - b equates to zero, then order will remain the same.

If my numbers array above had a duplicate number, this value would occur once.



Also, on the side note, if you wanted to sort in descending order, you could do b - a, which would sort inversely.



As as example,



array of 5, 5, 4

If a - b, was 5 minus 5, it would result to zero.






Thoughts



To wrap up, if you wanted to apply sort method to an array of numbers in ascending order, be sure to pass in a function like (a, b) => a - b;






Credits



https://forum.freecodecamp.org/t/arr-sort-a-b-a-b-explanation/167677

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

https://www.youtube.com/watch?v=CTHhlx25X-U

https://www.freecodecamp.org/news/how-to-sort-javascript-array-accurately/

https://www.freecodecamp.org/news/how-does-the-javascript-sort-function-work/

SOC Incident Playbook: Vulnerability Remediation & Verification
title: Detect Exploitation - Array Method Sort on Numbers;
id: ec94eb30-c3fe-4414-92d7-5d1f26522a3b
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Array Method Sort on Numbers;" ascii wide
    condition:
        any of them
}
Infrastructure Blast Radius & Exposure
LOCALIZED
Perimeter & External Ingress
GEFÄHRDET (85%)
Lateral Movement & Pivot
Geringes Risiko
Data Stores & Crown Jewels
Geringes Risiko
Supply Chain & Cascading Reach
Geringes Risiko
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Array Method Sort on Numbers;.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Array Method Sort on Numbers;

Thematisch verwandte Begriffe: Array, Method, Sort, Numbers · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger • Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick